Sqlsrv for PHP 5.6 on WAMP server

2020-02-08 08:32发布

问题:

After looking so many posts about this problem, I don't understand why it don't work because it should be working. I will post all the information I have so far:

  • Windows 10 64-bit

  • WampServer 3 64-bit (http://www.wampserver.com/)

  • PHP 5.6.16

  • Apache 2.4.17

  • Microsoft SQL Server 2016

I downloaded SQLSRV32.exe from microsoft. I extracted the dll files to C:\wamp\bin\php\php5.6.16\ext.

In my php.ini given by wampserver:

  • extension_dir = "c:/wamp/bin/php/php5.6.16/ext/"

  • extension=php_sqlsrv_56_ts.dll

  • extension=php_pdo_sqlsrv_56_ts.dll

I have php5ts.dll in my php5.6.16 folder, so I think I have thread safe which is why I am using ts.dll ones.

If I'm in phpinfo() I should see a 'sqlsrv' section in there, but I don't see one, so I guess I did something wrong here somewhere?

I even did restart on wampserver many times and run as an administrator. It still don't show up on phpinfo()... But I can see this in php extension at the Wampserver:

Any ideas to what I did wrong or why it don't show up in phpinfo()?

回答1:

I have found what was the problem.

It seems that I was using microsoft 32-bit sqlsrv driver, which don't work with wampserver 3 64-bit.

Official Microsoft SQL Server Driver for PHP: Here 32 bit - use this if you have a 32bit wampserver.

Unofficial Microsoft SQL Server Driver for PHP: Here 64 bit - use this if you have a 64bit server.

After using the unofficial version, it showed up on phpinfo()!

Anyway, I hope this answer is useful to people who have spend looking around for an answer in hours... or whatever, I hope it was useful.