PHP PDO for SQL SERVER [duplicate]

1

Good afternoon,

I'm trying to connect to my PHP pages in MS SQL SERVER using PDO, but I'm having trouble. I tried to use the PHP manual, but I'm getting confused and I'm not getting it. The page is returning this error: Failed to get DB handle: could not find driver. I tried downloading the drivers from microsoft's website, but it did not work either. I looked here in the forum and nothing too, I looked at these posts: PDO Drivers for SQL Server How to connect PHP 5.6 to Sql Server 2008 ? Error trying to connect bd MSSQL Server using PDO

NOTE: I'm using windows 10; PHP version 5.6.25; SQL SERVER 2014 EXPRESS;

Thank you!

    
asked by anonymous 22.01.2017 / 20:02

1 answer

0

You will need some .dll files that you can find at the following link:   link Since your PHP is 5.6, download the SQLSRV32 file.

After downloading the file, you will extract it, there you will have the necessary dlls.

use phpinfo () to check PHP Extension Build. .intheexamplecaseyouwillhavetocopythedllsthathavephp5.6_ts.dll,ie:php_pdo_sqlsrv_56_ts.dll,andphp_sqlsrv_56_ts.dll,Copythesefilestotheirdirectories,C:/.../php/extandalsoforC:/windows/system32/and/orforC:/windows/SysWOW64if64-bitcomputer.

Whenyoudothisyoushouldopenphp.iniandintheextensionsessionyoushouldaddthefollowinglines:

extension=php_sqlsrv_56_ts.dllextension=php_pdo_sqlsrv_56_ts.dll

andremovethe";" of the line extension = php_pdo_odbc.dll, if it is still commented.

YouwillalsoneedtoinstallMicrosoft®ODBCDriverforSQLServer[NativeClient]thatwilldependonyourdatabaseinthecaseasanexampleIwillpasstheMicrosoft®ODBCDriver11linktoSQLServer.

link

After the previous steps are fully installed. you should restart apache.

If everything is correct you can re-access phpinfo () and you can search for sqlsrv

andthenpdo_sqlsrv pdo_sqlsrv http://www.synet.sk/images/cms/pdo_sqlsrv_phpinfo.png I hope I have helped.

    
22.01.2017 / 23:52