Fatal error: Call to Undefined Function oci_connect()

Asked

Viewed 6,870 times

0

Error connecting to Oracle database. Below is the code in PHP:

<?php 
$ora_bd = "(DESCRIPTION=
      (ADDRESS_LIST=
        (ADDRESS=(PROTOCOL=TCP) 
          (HOST=192.168.0.249)(PORT=1521)
        )
      )
      (CONNECT_DATA=(SERVICE_NAME=CSTESTE))
 )"; 

$ora_conexao = oci_connect('refeitorio', 'tiete2018', $ora_bd);

if (!$ora_conexao) { 
$erro = oci_error();
    trigger_error(htmlentities($erro['message'], ENT_QUOTES), E_USER_ERROR);
    exit;
}else{                                                         
echo "Conectado com Sucesso.";  
}

Recalling that I have already enabled the following commands on php.ini

extension=php_oci8.dll
extension=php_pdo_oci.dll
extension=php_oracle.dll

The following error appears:

Fatal error: Uncaught Error: Call to Undefined Function oci_connect() in C: wamp64 www Sistema Refeicao Core Testecon.php:11 Stack trace: #0 {main} thrown in C: wamp64 www Sistema Refeicao Core Testecon.php on line 11

  • This error happens when the extension has not been installed. Only enable php.ini not enough. There’s something else you did?

  • Already installed instantclient on your system? https://answall.com/a/71364/4751

  • I already have the client installed on my machine. I use this client because I have 2 software using Oracle, path: C: oracle product 10.2.0 client_1

  • what version of your php?

  • 5.6.31, but also tried version 7.0.23

  • @J.C.Galhardi version 7 is only compatible with Instant client 12, be careful with it! I advise you to check all the steps I gave you and send me all the versions of everything you installed (client, php etc) and tb print of the environment variables configured

  • Was inside apache bin or inside bin/php/ext/ ???

  • I was able to put the Instant Client path ("C: instant_client") in the System Variables PATH and restart the PC.

  • In my case I needed to install XAMPP in 32 bit version. Download version of XAMPP 32 Bits

  • This solution works for Oracle 10.2.0 as well, but for this you need to download the instantclient. I used the instantane19.

Show 5 more comments

2 answers

3

I had this problem recently and the solution was this:

You lower the xamp or wamp 32 or 64 bits this will have to be your version of instant client oracle

after installing them with any version of php, when calling a function oci_oracle make a mistake.

You must then first enable the extensions on php.ini

an example of how to access php.ini in xamp:

inserir a descrição da imagem aqui

enable these extensions in that order:

extension=php_oci8.dll
extension=php_oci8_12c.dll
extension=php_oracle.dll

Note: if you do not have to enable, create and check the second, I put 12c because mine instant client is 12c.

After that you need to install the Instant client.

Opens the cmd AS ADMINISTRATOR goes to the location of the client and runs odbc_install

The next step is the most important, and that’s why I was taking a beating:

you need to add in PATH where is your oracle instant client:

insira o código aqui

and create TNS.ADMIN:

inserir a descrição da imagem aqui

does this for the two variable boxes, system and user:

inserir a descrição da imagem aqui

Done this, configure the file tnsnames. restart your machine, and you can use the functions oci.

Your Instant client must be in the same version as php, 32 or 64

by downloading php 7 in php.ini from him he asks for version 12 of instant client as you can see in the photo.

inserir a descrição da imagem aqui

  • I have 10g client. It would not be easier to install 32bit Wamp instead of having to install another client ?

  • you who know, just do the process for the client 10

  • I installed the 32x version, but it remains the same.

  • I will go up a virtual machine and do the process with the client 10g, but if you followed the right steps would have to work..

0

Dude, I had this problem and it took my sleep away for a few days. In my case the mistake was:

Fatal error: Call to Undefined Function oci_connect()

I could only solve by reinstalling everything in version 32 bits. For me it worked well. I installed XAMPP xampp-Win32-7.3.2-0-VC15 and enabled the extension:

 extension=oci8_12c

in php.ini. It is also worth checking if the extension is in the right place:

extension_dir="C:\xampp\php\ext"

After that you install Oracle Instant Client in the right version, in my case it was 32-bits in 12_2 version. The next step is to put this path in the environment variables, as the friend above spoke. After doing this it should be possible to see OCI8 on the phpinfo page:

enter image description here

Another tip is to check for errors in your php. To do this open the command prompt and navigate to the php folder of xampp. in my case it was "C: xampp php". Type in the 'php' command and see if there are any problems with the enabled dlls. If there is, the problem will be shown. If you want to do this as a test in your current version, see if there are any messages like "file not found" or "file is not win 32". If it appears, most likely this solution, passing to version 32 bits, will solve your problem!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.