Couldn't connect sqlsrv_connect with PHP 5.4.4
-
Wednesday, July 18, 2012 1:29 PMHi,
I'm trying to configure the SQL Server driver to run on PHP 5.4.4, I downloaded the package Drivers 3.0 (my SQL Server is 2008).
I set up Apache and PHP.ini started properly, without generating any error, I set the sqlsrv_54_ts as an extension, but in my server when I try to make the connection to the database, nothing happens.
On another computer with version 5.3 of php, the connection string works, but in this server with version 5.4, no failures in the function was informed, but does not connect to the database.
Someone tell me what might be happening?
All Replies
-
Wednesday, July 18, 2012 2:15 PM
Hi
This is a question with a few different answers, depending on your system...
Please can you post the following information:
- Have you installed the SQL Server Native Client 2012 on your computer that's running PHP? If so, which version?
- Have you checked your PHP error log - are there any messages about the SQLSRV driver?
- What version of Windows is PHP running on (and is it a 32 or 64 bit version)?
- What build of Apache do you have? There are versions of Apache built with different compilers - it could be VC6, VC9 or VC10. You must have a version of Apache built with either VC9 or VC10, available from http://www.apachelounge.com/download/...
- Which Apache PHP interface are you using? It could be Apache ISAPI or php5_module or FastCGI - check to see if there is a section of your phpinfo() titled 'Apache' - if there is, you should have a thread-safe (TS) version of PHP.
- What build of PHP do you have? This is not just the version - from phpinfo() you can get this from the settings named "PHP Extension Build" and "Architecture".
- Are you connecting with sqlsrv_connect() using a user name and password, or no user name and password (Windows credentials)?
It's possible when you go through this list you will be able to solve your own problem. Please let us know how you get on.
Rob
- Edited by Robert Johnson Wednesday, July 18, 2012 2:22 PM
- Marked As Answer by Iric WenModerator Friday, July 27, 2012 7:31 AM
- Unmarked As Answer by Jonathan GuerinMicrosoft Employee Monday, July 30, 2012 2:57 PM
- Proposed As Answer by Jonathan GuerinMicrosoft Employee Monday, July 30, 2012 2:58 PM
- Marked As Answer by Jonathan GuerinMicrosoft Employee Saturday, August 04, 2012 1:14 PM
-
Wednesday, August 01, 2012 12:41 PM
-
Monday, September 03, 2012 3:06 PM
I think i got nearly the same error thats why i am adding my question to this post.
I have got a PC which is running XAMPP with PHP 5.4.4 on it its a 64bit Windows 7 PC.
And i have got a Server which is running MS SQL 2008 R2 in 64bit (i guess) on a 2008 R2 Windows Data Center edition.
When i try to connect to the MSSQL Server the following msg appears.
Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -49 [code] => -49 [2] => This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 ) [1] => Array ( [0] => IM002 [SQLSTATE] => IM002 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified [message] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ) )
- Have you installed the SQL Server Native Client 2012 on your computer that's running PHP? If so, which version? -- Well yes, I did install the 64bit version
- Have you checked your PHP error log - are there any messages about the SQLSRV driver? -- Nope
- What version of Windows is PHP running on (and is it a 32 or 64 bit version)? -- windows 7 64bit
- What build of Apache do you have? There are versions of Apache built with different compilers - it could be VC6, VC9 or VC10. You must have a version of Apache built with either VC9 or VC10, available from http://www.apachelounge.com/download/... -- VC9
- Which Apache PHP interface are you using? It could be Apache ISAPI or php5_module or FastCGI - check to see if there is a section of your phpinfo() titled 'Apache' - if there is, you should have a thread-safe (TS) version of PHP. -- There is no section like Apache in my phpinfo. I installed xampp to install it.
- What build of PHP do you have? This is not just the version - from phpinfo() you can get this from the settings named "PHP Extension Build" and "Architecture". -- API20100525,TS,VC9
- Are you connecting with sqlsrv_connect() using a user name and password, or no user name and password (Windows credentials)? -- im using username+password
What could be wrong?
-
Monday, September 03, 2012 4:44 PM
Hi Fretful,
Did you follow the link in the error and install the SQL Server 2012 Native Client? The PHP Driver requires it.
Thanks,
Jonathan
This posting is provided 'AS IS' with no warranties, and confers no rights.
-
Monday, September 03, 2012 5:30 PM
Fretful
Yes, Jonathan's right. Point 1 says Native Client 2012 (64 bit is correct). You can get it here: http://www.microsoft.com/en-us/download/details.aspx?id=29065#SNAC
And it looks like you already have the correct driver installed - one or both of these:
- php_sqlsrv_54_ts.dll
- php_pdo_sqlsrv_54_ts.dll
Rob
- Proposed As Answer by Fretful Tuesday, September 04, 2012 7:58 AM
-
Tuesday, September 04, 2012 8:00 AMThank you! After installing the Native Client 2012 64bit the connection worked! I am wondering because I downloaded the native client mentioned in the error msg but it did not work.
-
Tuesday, September 04, 2012 5:26 PM
Thank you! After installing the Native Client 2012 64bit the connection worked! I am wondering because I downloaded the native client mentioned in the error msg but it did not work.
Hi Fretful,
I just followed the links and found the information is actually correct. Did you accidentally install the dependencies for the Version 2.0 driver?
"Version 3.0 of the driver requires Microsoft SQL Server 2012 Native Client. You can download Microsoft SQL Server 2012 Native Client from the SQL Server 2012 feature pack page."
Cheers,
Jonathan
This posting is provided 'AS IS' with no warranties, and confers no rights.
-
Friday, September 07, 2012 8:27 AMHii this problem i have faced also during developing on php development so any one has perfect answer? so please help
-
Friday, September 07, 2012 11:07 AM
There is no perfect answer to this question, it is paradoxical. The answers are all over this forum, all different, and all correct at the same time.
Here is a similar question: What colour is a grape?
Original answer edited:
I wasn't happy with my original answer to this, so I have written a blog page with all the combinations possible from Microsoft's builds - it's still not easy to follow but might help: http://robsphp.blogspot.co.uk/2012/09/how-to-install-microsofts-sql-server.html
Rob- Edited by Robert Johnson Friday, September 07, 2012 11:11 AM
- Edited by Robert Johnson Friday, September 07, 2012 11:13 AM
- Edited by Robert Johnson Friday, September 07, 2012 11:14 AM
- Edited by Robert Johnson Friday, September 07, 2012 11:15 AM Numerous attempts to make ol and ul formating work, to no avail.
- Edited by Robert Johnson Friday, September 07, 2012 1:01 PM Better answer
- Marked As Answer by Jonathan GuerinMicrosoft Employee Saturday, September 08, 2012 2:15 AM
-
Saturday, September 08, 2012 2:15 AMGreat post, Robert, thanks!
This posting is provided 'AS IS' with no warranties, and confers no rights.

