Win7 64位系统下PHP连接Oracle数据库,win7oracle
Win7 64位系统下PHP连接Oracle数据库,win7oracle
下面讲下配置过程
一、下载oracle instantclient
下载地址:http://www.oracle.com/technetwork/topics/winx64soft-089540.html
下载 instantclient-basic-windows.x64-11.2.0.4.0
解压路径:D:\Program Files (x86)\Oracle64Client\instantclient_11_2
*注:客户端需要对应数据库版本。
二、配置系统环境变量
在PATH环境变量后加入:;D:\Program Files (x86)\Oracle64Client\instantclient_11_2
三、配置PHP支持OCI扩展
修改配置文件php.ini
开启配置如下
四、重启Apache服务测试
使用探针函数phpinfo()查看扩展是否开启,如果出现下图说明扩展开启
五、测试数据库连接
在站点根目录编写oracle.php,我连接的是虚拟机CentOS中的Oralce数据库
代码如下:
<?php $conn = ocilogon('test','test','192.168.23.131:1521/dev'); if (!$conn) { $Error = oci_error(); print htmlentities($Error['message']); exit; } else { echo "Connected Oracle Successd!"."<br>"; ocilogoff($conn); } ?>
浏览器地址栏输入 http://localhost/oracle.php
显示Connected Oracle Successd!说明数据库连接成功。
我遇到过,并且解决了。
单位的服务器配置的CENTOS 5.5 X64,我的电脑也是win7 x64,安装的oracle 10g x86 client,可以通过sqlplus@的方式连接到数据库,但是安装了toad和pl/sql就是连接不上。起初我也问是不是一定要把操作系统换成32位。
后来经过测试,发现原因很简单,因为安装在了C盘的Program Files (X86)文件夹下。这个文件夹很特殊,是为了提高64位兼容性,搞得兼容32位模式的文件夹,一般32位的软件默认安装在这,而且会以32位运行,所以会导致toad,PL/SQL无法连接。
所以解决方法非常简单,只要把PL/SQL,TOAD安装在D盘,就可以通过连接。
win7+64位+Oracle+11g+64位下使用PLSQL+Developer+的解决办法
1)安装Oracle 11g 64位 (这部分就不说了吧)
2)安装32位的Oracle客户端( instantclient-basic-win32-11.2.0.1.0)
下载instantclient-basic-win32-11.2.0.1.0.zip (一定得是32位的,不要下错了版本,Oracle官网有下载),将其解压至Oracle安装目录的Product下(本机命名为:instantclient_11_2):D:\Oracle\app\dd\product\instantclient_11_2。
拷贝数据库安装根目录下的一个目录D:\Oracle\app\dd\product\11.2.0\dbhome_1\NETWORK到Oracle客户端目录下D:\Oracle\app\dd\product\instantclient_11_2(其实只需要 NETWORK\ADMIN\tnsnames.ora)
3)安装PL/SQL Developer
安装 PL/SQL Developer,在perference->Connection里面设置OCI Library和Oracle_Home,例如本机设置为:
Oracle Home :D:\Oracle\app\dd\product\instantclient_11_2
OCI Library :D:\Oracle\app\dd\product\instantclient_11_2\oci.dll
4) 设置环境变量(修改环境变量)
对于NLS_LANG环境变量, 最好设置成和数据库端一致, 首先从数据库端查询字符集信息:
SQL> select userenv('language') nls_lang from dual;
NLS_LANG
----------------------------------------------------
SIMPLIFIED CHINESE_CHINA.ZHS16GBK
右击"我的电脑" - "属性" - "高级" - "环境变量" - "系统环境变量":
1>.点击"新建", 变量名设置为"NLS_LANG", 变量值设置为"SIMPLIFIED CHINESE_CHINA.ZHS16GBK", 点击"确定";
2>.新建环境变量“TNS_ADMIN”,值为“D:\Oracle\app\dd\product\instantclient_11_2”
最后点击"确定"退出.
启动 PL/SQL Developer ,运行无问题。...余下全文>>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The future of PHP will be achieved by adapting to new technology trends and introducing innovative features: 1) Adapting to cloud computing, containerization and microservice architectures, supporting Docker and Kubernetes; 2) introducing JIT compilers and enumeration types to improve performance and data processing efficiency; 3) Continuously optimize performance and promote best practices.

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP remains important in modern web development, especially in content management and e-commerce platforms. 1) PHP has a rich ecosystem and strong framework support, such as Laravel and Symfony. 2) Performance optimization can be achieved through OPcache and Nginx. 3) PHP8.0 introduces JIT compiler to improve performance. 4) Cloud-native applications are deployed through Docker and Kubernetes to improve flexibility and scalability.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.
