PHP PDO mssql错误 [英] PHP PDO mssql error

查看:90
本文介绍了PHP PDO mssql错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mssql pdo for PHP 5.3.1,它正在运行而没有任何问题,突然我发现,从php PDO运行时,我所有的插入查询都失败了,如果我回显查询并在SQL Server Management Studio中运行它,它运行没有任何错误.下面是我的回声查询

I was using mssql pdo for PHP 5.3.1, It was running without any problems, suddenly I have found, all my insert queries fails while running from php PDO, If I echo the query and run it in SQL server Management studio, It runs without any error. below is my echo query

INSERT INTO contactus(title, first_name, last_name, email) VALUES('Mr', 'Robin', 'Michael', 'robin@robin.com')

以下是错误

Array ( [0] => HY000 [1] => 10007 [2] => Incorrect syntax near 'Mr'. [10007] (severity 5) [INSERT INTO contactus(title, first_name, last_name, email) VALUES('Mr] [3] => -1 [4] => 5 ) 

任何人都可以帮助我解决此问题吗?

Can anyone please help me resolve this issue??

推荐答案

最后,我发现了问题,这是由于计算机和Windows服务器上的Windows最近更新所致.此更新后,mssql pdo驱动程序将引发此错误.我已经从Microsoft网站下载了sqlsrv20驱动程序并放置了文件
php扩展目录中的php_pdo_sqlsrv_53_ts_vc6.dll并在php.ini文件中添加了新扩展名,例如extension = php_pdo_sqlsrv_53_ts_vc6.dll并更改了pdo连接性

Finally, I have found the issue, This is because of recent windows update on my machine and our windows server. After this update mssql pdo driver throws this error. I have downloaded sqlsrv20 driver from microsoft website and placed the file
php_pdo_sqlsrv_53_ts_vc6.dll inside php extension directory and added new extension in php.ini file like extension=php_pdo_sqlsrv_53_ts_vc6.dll and changed the pdo connectivity

$dbcon = new PDO( "sqlsrv:server=$conf->host;Database=$conf->db_name", $conf->db_user, $conf->db_pwd); 

注意:对于Wamp服务器,用户还需要检查apache中的php.ini,并且需要在apache下的php.ini文件中添加扩展名.

Note : for wamp server users needs to check php.ini in apache also and needs to add the extension in php.ini file under apache.

这篇关于PHP PDO mssql错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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