PHP PDO mssql error

2019-09-17 11:23发布

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')

below is the error

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??

1条回答
看我几分像从前
2楼-- · 2019-09-17 11:44

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); 

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.

查看更多
登录 后发表回答