Fatal error: Call to undefined function oci_connect ()

0

Error connecting to Oracle database. Here 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.";  
}

Remembering that I have already enabled the following commands in 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 \ System \ Recovery \ Core \ TestCon.php: 11 Stack trace: # 0 {main} thrown in C: \ wamp64 \ www \ System \ Refeicao \ Core \ TesteCon.php on line 11

    
asked by anonymous 12.02.2018 / 17:38

1 answer

3

I recently had this problem and the solution was this:

You drop 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 , calling a function oci_oracle will give error.

You then need to first enable extensions in php.ini

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

enabletheseextensionsinthisorder:

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

Note:ifyoudonothavetoenable,createandcheckthesecond,Iput12cbecausemyinstantclientis12c.

Afterthatyouneedtoinstalltheinstantclient.

Opens%with%ASADMINISTRATORgoestotheinstantclientlocationandrunscmd

Thenextstepisthemostimportant,whichiswhyIwastakingabeating:

Youneedtoaddinodbc_installwhereyourPATHis:

andcreatetheTNS.ADMIN:

Dothisforboththesystemanduservariablesboxes:

Whenyoudothis,setthetnsnames.orafiletorestartyourmachine,andyoucanusetheoracleinstantclientfunctions.

  

Yourinstantclienthastobeinthesamephpversion,32or64

downloadingphp7inphp.iniitasksforversion12ofociasyoucanseeinthephoto.

    
14.02.2018 / 14:23