How to connect php to oracle database (test successful), oracle database_PHP tutorial

WBOY
Release: 2016-07-12 08:50:43
Original
993 people have browsed it

How to connect php to oracle database (test successful), oracle database

This article briefly analyzes how php connects to oracle database. Share it with everyone for your reference, the details are as follows:

PHP provides two sets of functions to connect to Oracle, namely ORA_ and OCI functions. The ORA_ function is slightly outdated. The OCI function update is said to be better. The usage syntax of the two is almost the same. Your PHP installation options should support the use of both.

Since OCI functions need 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 install oracle client software on the connection end. You can download it for free from http://www.oracle.com. This is necessary, otherwise an undefined method error will be reported.

Steps:

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

<&#63;php
$conn = oci_connect('用户名', '密码', '远程数据库名(eg.//192.168.1.133/orcl)');
if (!$conn) {
  $e = oci_error();
  print htmlentities($e['message']);
  exit;
}else {
  echo "连接oracle成功!";
}
&#63;>

Copy after login

Possible errors:

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

Solution: Copy the php_oci8.dll file in the php/ext directory to the system32 directory. If that still doesn’t work, copy the Oracle 10g Instant Client installation directory to /product/10.2.0/db_2/ Copy the oci.dll file in the BIN directory to system32.

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

Solution: Restart the machine. If that still doesn’t work, install Oracle 10g Instant Client.

Readers who are interested in more PHP-related content can check out the special topics of this site: "Summary of PHP database operation skills based on pdo", "PHP MongoDB database operation skills collection", "php object-oriented programming introductory tutorial", "php Summary of String Usage", "Introduction Tutorial on PHP MySQL Database Operation" and "Summary of PHP Common Database Operation Skills"

I hope this article will be helpful to everyone in PHP programming.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1133082.htmlTechArticleHow to connect php to oracle database (test successful), oracle database This article briefly analyzes the method of php to connect to oracle database. Share it with everyone for your reference, the details are as follows: PHP provides...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!