PHP Methods for connecting Oracle databases (test success) _php tips

Source: Internet
Author: User
Tags apache error log file copy oracle database

This paper briefly analyzes the method of PHP connecting to Oracle database. Share to everyone for your reference, specific as follows:

PHP provides two sets of functions that are connected to Oracle, namely the Ora_ and OCI functions. Where the Ora_ function is slightly stale. The OCI function update is said to be better. The use of the syntax is almost the same. Your PHP installation options should be able to support both use.

Because the OCI function accesses Oracle8 above the database needs to use Oracle8 call-interface (OCI8), this extension module requires a Oracle8 client function library, so you need to connect to the remote database, you also need to install Oracle client software on the connection side , can go to http://www.oracle.com free download, this is necessary, otherwise will report the method is not defined wrong.

Steps:

1, install Apache and PHP.
2, install Oracle 10g Instant Client (or other version).
2, open the extension=php_oci8 extension in php.ini.
3, the Php/ext directory under the Php_oci8.dll file copy to the System32 directory.
4, write test script test.

<?php
$conn = oci_connect (' username ', ' password ', ' Remote Database name (EG.//192.168.1.133/ORCL) ');
if (! $conn) {
  $e = Oci_error ();
  Print htmlentities ($e [' message ']);
  Exit;
} else {
  echo "connects Oracle successfully! ";
}
? >

Errors that may occur:

1, call to undefined function oci_connect () ...: This is because the php_oci8.dll is not found, check Apache error log error.log may see: PHP startup:unable To load dynamic liberaries Php_oci8.dll ...

Workaround: Copy the Php_oci8.dll file under the Php/ext directory to the System32 directory, and if not, place the Oracle 10g Instant Client Installation directory/product/10.2.0/db_2/ The Oci.dll files in the bin directory are copied to the System32.

2, Ocienvnlscreate () failed ..... PATH includes the directory with Oracle Instant Client libraries

Workaround: reboot the machine and, if not, install Oracle 10g Instant Client.

More about PHP Interested readers can view the site topics: "PHP based on PDO Operation Database Skills Summary", "PHP+MONGODB Database Operation Skills Encyclopedia", "PHP object-oriented Programming Program Introduction", "PHP string (String) Usage Summary", " Introduction to PHP+MYSQL Database operations and a summary of PHP common database operations Tips

I hope this article will help you with the PHP program design.

Related Article

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.