search
Homephp教程php手册php连接oracle数据库的方法(测试成功),oracle数据库

php连接oracle数据库的方法(测试成功),oracle数据库

本文简单分析了php连接oracle数据库的方法。分享给大家供大家参考,具体如下:

PHP提供了两套函数与Oracle连接,分别是ORA_和OCI函数。其中ORA_函数略显陈旧。OCI函数更新据说更好一些。两者的使用语法几乎相差无几。你的PHP安装选项应该可以支持两者的使用。

由于OCI函数访问oracle8以上的数据库需要用到Oracle8 Call-Interface(OCI8),这个扩展模块需要oracle8的客户端函数库,因此需要连接远程数据库的话,还需要连接端安装oracle客户端软件,可以到http://www.oracle.com免费下载,这是必须的,否则会报方法未定义错。

步骤:

1、安装apache和php。
2、安装Oracle 10g Instant Client(或其他版本)。
2、在php.ini中打开extension=php_oci8扩展。
3、将php/ext目录下的php_oci8.dll文件拷贝到system32目录下。
4、编写测试脚本测试。

<&#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;>

可能出现的错误:

1、call to undefined function oci_connect()......:这是因为没找到php_oci8.dll,检查apache的错误日志error.log可能会看到:php startup :unable to load dynamic liberaries php_oci8.dll......

解决方法:将php/ext目录下的php_oci8.dll文件拷贝到system32目录下,如果还不行,将Oracle 10g Instant Client安装目录下/product/10.2.0/db_2/BIN目录中的oci.dll文件拷贝到system32下。

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

解决方法:重启机器,如果还不行,安装Oracle 10g Instant Client。

更多关于PHP相关内容感兴趣的读者可查看本站专题:《PHP基于pdo操作数据库技巧总结》、《PHP+MongoDB数据库操作技巧大全》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家PHP程序设计有所帮助。

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.