What are the most important conditions for a PHP connection with ORACLE?
I already wrote these extensions in PHP.ini and it did not work
extension=oci8_12c ; Use with Oracle Database 12c Instant Client
extension=php_oci8.dll
extension=php_oci8_12c.dll
extension=php_oracle.dll
extension=pdo_odbc
extension=pdo_pgsql
Code Used
<?php
$conn="(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.9)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = PRD)
(SERVER = DEDICATED)
)
)";
$conexao = oci_connect('DBA', '123', $conn);
if (isset ($conexao) || empty($conexao)){
$erro = oci_error();
trigger_error(htmlentities($erro['erro'], ENT_QUOTES), E_USER_ERROR);
exit;
}
echo"Hello";
?>
Errors
Fatal error: Uncaught Error: Call to undefined function oci_connect() in C:\wamp64\www\Teste\testes\conexaooracle.php on line 12
Error: Call to undefined function oci_connect() in C:\wamp64\www\Teste\testes\conexaooracle.php on line 12
The most important thing is to install the Oracle client libraries. If you don't have them on your machine, you can get these from Oracle Instant Client
Once unzipped, set PATH environment variable to find them.
Only uncomment one of the extension
lines to include OCI8. You probably just need
extension=oci8_12c ; Use with Oracle Database 12c Instant Client
This will actually work with 12c or later versions of Oracle Client libraries.
A useful PHP Oracle resource is the back half of http://www.oracle.com/technetwork/topics/php/underground-php-oracle-manual-098250.html
PS you can simplify your connection to:
$conexao = oci_connect('DBA', '123', '192.168.0.9/PRD');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.