时间:2021-07-01 10:21:17 帮助过:25人阅读
"myDB1");/* Connect using Windows Authentication. */$conn = sqlsrv_connect( $serverName, $connectionInfo);if( $conn === false ){ echo "Unable to connect."; die( print_r( sqlsrv_errors(), true));}else echo "great! ";?>
配置php.ini,??php?mssql的?展即可.
PDO drivers mysql, sqlite, sqlsrv ???
只有这个?
你单写一个程序
看看输出什么
PDO drivers mysql, sqlite, sqlsrv ???
只有这个?
你单写一个程序
看看输出什么
PDO
---------------------------------------
PDO support enabled
PDO drivers mysql, sqlite, sqlsrv
确实只有这几个呀!是不是还要安装啥呢?
配置php.ini,??php?mssql的?展即可.
已经百度了好多下了,发现对5.2以下版本可以用,以上版本的因为sql server数据库版本不同,所以这方法不推荐了。而且我也尝试了下载php_mssql.dll,然后添加注释,不起作用呀
我用的php版本是5.2.6 一直在正常使用中.
不要开玩笑!
单独一句
var_dump(function_exists('sqlsrv_connect'));
这么可能是 HTTP 错误 500.0 - Internal Server Error
至多是 bool(false)
不要开玩笑!
单独一句
var_dump(function_exists('sqlsrv_connect'));
这么可能是 HTTP 错误 500.0 - Internal Server Error
至多是 bool(false)
呵呵,刚才确实是那样的哈!
现在装成5.3啦,又下载了microsoft driver for PHP for sql server,终于不出错http500啦!
就是5.3的ini文件和5.4的差别很大,不但要填键值,还要添加键名称
不要开玩笑!
单独一句
var_dump(function_exists('sqlsrv_connect'));
这么可能是 HTTP 错误 500.0 - Internal Server Error
至多是 bool(false)
呵呵,刚才确实是那样的哈!
现在装成5.3啦,又下载了microsoft driver for PHP for sql server,终于不出错http500啦!
就是5.3的ini文件和5.4的差别很大,不但要填键值,还要添加键名称 那问题是否解决?
Unable to connect.
Array ( [0] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 2 [code] => 2 [2] => [Microsoft][SQL Server Native Client 11.0]Named Pipes Provider: Could not open a connection to SQL Server [2]. [message] => [Microsoft][SQL Server Native Client 11.0]Named Pipes Provider: Could not open a connection to SQL Server [2]. ) [1] => Array ( [0] => HYT00 [SQLSTATE] => HYT00 [1] => 0 [code] => 0 [2] => [Microsoft][SQL Server Native Client 11.0]Login timeout expired [message] => [Microsoft][SQL Server Native Client 11.0]Login timeout expired ) [2] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 2 [code] => 2 [2] => [Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. [message] => [Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. ) )
------------------------------------------------------------------------------------------
唉,又浪费俩小时,还是不行呀!找到问题了,但是不知道怎么解决的!
我用的微软的web platform install安装PHP,它会自动安装一个SQL server 2012 native client的软件。只要把它卸载了,PHP就再也无法运行了,即使装了fastcgi也没用。但是装了它以后,我的sql server 2008数据库就肯定是连不起来的。可以加分加到100粉的,请大侠再给看下吧!
Unable to connect.
Array ( [0] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 2 [code] => 2 [2] => [Microsoft][SQL Server Native Client 11.0]Named Pipes Provider: Could not open a connection to SQL Server [2]. [message] => [Microsoft][SQL Server Native Client 11.0]Named Pipes Provider: Could not open a connection to SQL Server [2]. ) [1] => Array ( [0] => HYT00 [SQLSTATE] => HYT00 [1] => 0 [code] => 0 [2] => [Microsoft][SQL Server Native Client 11.0]Login timeout expired [message] => [Microsoft][SQL Server Native Client 11.0]Login timeout expired ) [2] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 2 [code] => 2 [2] => [Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. [message] => [Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. ) )
------------------------------------------------------------------------------------------
唉,又浪费俩小时,还是不行呀!找到问题了,但是不知道怎么解决的!
我用的微软的web platform install安装PHP,它会自动安装一个SQL server 2012 native client的软件。只要把它卸载了,PHP就再也无法运行了,即使装了fastcgi也没用。但是装了它以后,我的sql server 2008数据库就肯定是连不起来的。可以加分加到100粉的,请大侠再给看下吧!
引用的DLL文件版本不对
还是版本不兼容的问题....
最后也没解决呀,逼得只能现学asp.net了,要不是需求SQL server,我用mysql轻松就搞定了。
微软太自私了,明显是想让P(拍)H(黄)P(片)的饿死呀!!!
我的可以,PHP Version 5.4.16 链接 sql2008 链接成功
用sqlsrv 3.0 ,2.0的没有试过,方法是
php.ini 加入
extension=php_pdo_sqlsrv_54_nts.dll
extension=php_sqlsrv_54_nts.dll
数据库链接:
$conn= new PDO("sqlsrv:server=127.0.0.1;database=abc","user","123456") or die ("PDO Connection faild.");