Php connection to the oracle database (test successful), oracle Database

Source: Internet
Author: User
Tags apache error log

Php connection to the oracle database (test successful), oracle Database

This article briefly analyzes how php connects to the oracle database. We will share this with you for your reference. The details are as follows:

PHP provides two sets of functions connected to Oracle: ORA _ and OCI. The ORA _ function is somewhat outdated. OCI function updates are said to be better. The syntax is almost the same. Your PHP installation options should support both.

Because the OCI function needs to use oracle8 Call-Interface (OCI8) to access databases above Oracle8, this extension module requires the client function library of oracle8. Therefore, if you need to connect to a remote database, you also need to connect to install the oracle client software, you can go to the http://www.oracle.com for free download, this is required, otherwise the method will be reported undefined error.

Steps:

1. install apache and php.
2. Install Oracle 10g Instant Client (or another version ).
2. Open the extension = php_oci8 extension in php. ini.
3. Copy the php_oci8.dll file under the php/ext directory to the system32 directory.
4. Write a test script for testing.

<? Php $ conn = oci_connect ('username ', 'Password', 'remote Database Name (eg. // 192.168.1.20./ orcl)'); if (! $ Conn) {$ e = oci_error (); print htmlentities ($ e ['message']); exit;} else {echo "connection to oracle successful! ";}?>

Possible errors:

1. call to undefined function oci_connect ()......: This is because php_oci8.dll is not found and apache error log error is checked. log may see: php startup: unable to load dynamic liberaries php_oci8.dll ......

Solution:Copy the php_oci8.dll file under the php/ext directory to the system32 directory. If not, install oci in the/product/10.2.0/db_2/BIN directory of the Oracle 10g Instant Client. copy the dll file to system32.

2. OCIEnvNlsCreate () failed ...... PATH provided des the directory with Oracle Instant Client libraries

Solution:Restart the machine. If not, install the Oracle 10g Instant Client.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.