致命错误:调用未定义函数sqlsrv_connect() [英] Fatal error: Call to undefined function sqlsrv_connect()

查看:586
本文介绍了致命错误:调用未定义函数sqlsrv_connect()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于相同主题的问题,我遇到了很多帖子,但是我仍然无法解决它,所以我问.我正在尝试在我的PHP脚本中连接到sql.我的连接字符串是:

I have come across quite a few post regarding the same subject question, however I am still unable to resolve it and so I ask. I am trying to connect to sql in my php script. My connection string is:

/* Specify the server and connection string attributes. */
$serverName = "xxx-PC\SQLExpress";
$connectionOptions = array("Database"=>"Salesforce");
$conn = sqlsrv_connect($serverName, $connectionOptions);
if($conn === false)
{
      die(print_r(sqlsrv_errors(), true));
}

我已经安装了以下文件,并将其包含在wamp文件夹下的php.ini文件中:C:\wamp\bin\php\php5.4.16:

I have installed and included the following in my php.ini file located under the wamp folder: C:\wamp\bin\php\php5.4.16:

extension=c:/wamp/bin/php/php5.4.16/ext/php_sqlsrv_53_ts.dll

我的wampserver运行良好,wampapachewampsqld服务也运行良好.我能够成功执行php.exe.但是,我无法建立与数据库所在的SQL Server 2008 R2的连接.请帮忙!

My wampserver is running fine and so are the wampapache and wampsqld services. I am able to execute php.exe successfully. However I am unable to make the connection to SQL Server 2008 R2 where my database is located. Please help!

当我尝试连接到SQL Server 2008 R2时,wamp服务器正在运行wampmysql服务.这可能是原因吗?我应该使用MySQL而不是SQL吗?有指针吗?

EDIT 1: The wamp server is running the wampmysql service while I am trying to connect to SQL Server 2008 R2. Could this be the reason? Should I be using MySQL instead of SQL? Any pointers?

尽管我在wamp服务器的bin文件夹中的php.ini文件中添加了extension=php_sqlsrv_54_ts.dll,但是当我运行phpinfo()时,我根本看不到sqlsrv部分.

EDIT 2: I do not see sqlsrv section at all when I run phpinfo() though I have added extension=php_sqlsrv_54_ts.dll in the php.ini file located in the bin folder of the wamp server.

推荐答案

This helped me get to my answer. There are two php.ini files located, in my case, for wamp. One is under the php folder and the other one is in the C:\wamp\bin\apache\Apachex.x.x\bin folder. When connecting to SQL through sqlsrv_connect function, we are referring to the php.ini file in the apache folder. Add the following (as per your version) to this file:

extension=c:/wamp/bin/php/php5.4.16/ext/php_sqlsrv_53_ts.dll

这篇关于致命错误:调用未定义函数sqlsrv_connect()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆