PHP Connection SQL Server 2008 not even up!

Source: Internet
Author: User
Tags sql server books mssql
The operating system is win server R2, the database is SQL Server 2008,php Version 5.4.14,
Look in the phpinfo of the output
-------------------------------------------------------------------------------------
PDO Support Enabled
PDO drivers MySQL, SQLite, sqlsrv

However, if you want to access the database using Sqlsrv, the "HTTP error 500.0" Prompt always appears,
-------------------------------------------------------------------------------------
Module Fastcgimodule
Notify Executerequesthandler
Handler php54_via_fastcgi
Error code 0x00000000


This is a routine that accesses the opcode that is actually copied from Microsoft Driver for PHP for SQL Server:
 
  "MyDB1");/* Connect using Windows authentication. */$conn = Sqlsrv_connect ($serverName, $connectionInfo), if ($conn = = = False) {     echo "unable to connect.
"; Die (Print_r (Sqlsrv_errors (), True));} Else
";? >


Reply to discussion (solution)

Configuring PHP.ini,?? Php?mssql's exhibition can be.

PDO drivers MySQL, SQLite, sqlsrv???
Only this one?
You write a single program

 See what the output is.


PDO drivers MySQL, SQLite, sqlsrv???
Only this one?
You write a single program

  See what the output is.

The output is HTTP error 500.0-internal Server error YES!
Isn't the PHP outfit right? Because it is the server2008 system, so with Microsoft that Web Platform installation installed PHP 5.4, did not find System32 FcgiXXX.dll, but Phpinfo () can also output information ....


Pdo
---------------------------------------
PDO Support Enabled
PDO drivers MySQL, SQLite, sqlsrv

These are the only ones! Is there anything else to install?

Configuring PHP.ini,?? Php?mssql's exhibition can be.
Baidu has been a lot under, found that the following version of 5.2 can be used, the above version because the SQL Server database version is different, so this method is not recommended. And I tried to download Php_mssql.dll, and then add a comment that doesn't work

I use the PHP version is 5.2.6 has been in normal use.

No kidding!
A single sentence
Var_dump (function_exists (' sqlsrv_connect '));
This could be an HTTP error 500.0-internal Server error
is at most bool (false)

No kidding!
A single sentence
Var_dump (function_exists (' sqlsrv_connect '));
This could be an HTTP error 500.0-internal Server error
is at most bool (false)
Oh, it was just like that ha!
Now it's 5.3, and you've downloaded Microsoft driver for PHP for SQL Server, and you're finally http500!
Is the 5.3 INI file and 5.4 difference is very large, not only to fill the key value, but also to add the key name


No kidding!
A single sentence
Var_dump (function_exists (' sqlsrv_connect '));
This could be an HTTP error 500.0-internal Server error
is at most bool (false)
Oh, it was just like that ha!
Now it's 5.3, and you've downloaded Microsoft driver for PHP for SQL Server, and you're finally http500!
Is the 5.3 INI file and 5.4 of the difference is very large, not only to fill the key value, but also to add the name of the key is the problem solved?

Unable to connect.
Array ([0] = = Array ([0] = = 08001 [SQLSTATE] = 08001 [1] = 2 [Code] = 2 [2] = = [Microsoft][sql Ser Ver Native Client 11.0]named Pipes provider:could not open a connection to SQL Server [2]. [Message] = [Microsoft][sql Server Native Client 11.0]named Pipes provider:could not open a connection to SQL server [2].) [1] = = Array ([0] = HYT00 [SQLSTATE] = HYT00 [1] = 0 [Code] = 0 [2] = [Microsoft][sql Serve R Native Client 11.0]login timeout expired [message] = [Microsoft][sql Server Native Client 11.0]login Timeout expired ) [2] = = Array ([0] = 08001 [SQLSTATE] = 08001 [1] = 2 [Code] = 2 [2] + = [Microsoft][sql Server Na tive Client 11.0]a network-related or instance-specific error have occurred while establishing A connection to SQL Server. Server is not a found or not accessible. Check If instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server BooksOnline. [Message] = [Microsoft][sql Server Native Client 11.0]a network-related or instance-specific error have occurred while Establishing a connection to SQL Server. Server is not a found or not accessible. Check If instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. ) )

------------------------------------------------------------------------------------------
Alas, another waste of two hours, or not! Found the problem, but do not know how to solve it!
I use Microsoft's Web Platform install PHP installed, it will automatically install a SQL Server Native Client software. As long as it is unloaded, PHP will no longer work, even if the installation of fastcgi is useless. But after it was installed, my SQL Server 2008 database was definitely not connected. You can add to the 100 powder, please take a look at the hero!

Unable to connect.
Array ([0] = = Array ([0] = = 08001 [SQLSTATE] = 08001 [1] = 2 [Code] = 2 [2] = = [Microsoft][sql Ser Ver Native Client 11.0]named Pipes provider:could not open a connection to SQL Server [2]. [Message] = [Microsoft][sql Server Native Client 11.0]named Pipes provider:could not open a connection to SQL server [2].) [1] = = Array ([0] = HYT00 [SQLSTATE] = HYT00 [1] = 0 [Code] = 0 [2] = [Microsoft][sql Serve R Native Client 11.0]login timeout expired [message] = [Microsoft][sql Server Native Client 11.0]login Timeout expired ) [2] = = Array ([0] = 08001 [SQLSTATE] = 08001 [1] = 2 [Code] = 2 [2] + = [Microsoft][sql Server Na tive Client 11.0]a network-related or instance-specific error have occurred while establishing A connection to SQL Server. Server is not a found or not accessible. Check If instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server BooksOnline. [Message] = [Microsoft][sql Server Native Client 11.0]a network-related or instance-specific error have occurred while Establishing a connection to SQL Server. Server is not a found or not accessible. Check If instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. ) )

------------------------------------------------------------------------------------------
Alas, another waste of two hours, or not! Found the problem, but do not know how to solve it!
I use Microsoft's Web Platform install PHP installed, it will automatically install a SQL Server Native Client software. As long as it is unloaded, PHP will no longer work, even if the installation of fastcgi is useless. But after it was installed, my SQL Server 2008 database was definitely not connected. You can add to the 100 powder, please take a look at the hero!

The referenced DLL file version is incorrect

or version incompatibility issues ....

Finally did not solve ah, forcing can only now learn ASP. NET, but if the need for SQL Server, I use MySQL easy to take care of.
Microsoft is too selfish, obviously want to let P (shoot) H (yellow) p (piece) Starve!!!

I can, PHP Version 5.4.16 link sql2008 Link succeeded
With SQLSRV 3.0, 2.0 did not try, the method is
PHP.ini Join
Extension=php_pdo_sqlsrv_54_nts.dll
Extension=php_sqlsrv_54_nts.dll

Database Links:
$conn = new PDO ("Sqlsrv:server=127.0.0.1;database=abc", "User", "123456") or Die ("PDO Connection faild.");

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.