Reputation: 79
I'm trying to establish a connection with PHP and MS SQL Server 2005. I'm using IIS 8 in Windows 8 and PHP version 5.3.28. I already done my research, I've found MSSQL PHP PDO (http://www.php.net/manual/en/ref.pdo-sqlsrv.connection.php and http://technet.microsoft.com/en-us/library/ff754357(v=sql.105).aspx), downloaded and enabled all of PDO related DLLs I've found from Microsoft website (Microsoft Drivers 3.0 for PHP for SQL Server) and assured they are reflecting in phpinfo().
extension=php_pdo_sqlsrv_52_nts_vc6.dll
extension=php_pdo_sqlsrv_53_nts.dll
extension=php_pdo_sqlsrv_53_nts_vc6.dll
extension=php_pdo_sqlsrv_53_nts_vc9.dll
extension=php_pdo_sqlsrv_54_nts.dll
extension=php_pdo_sqlsrv_54_nts.dll
extension=php_sqlsrv_54_nts.dll
extension=php_sqlsrv_53_ts_vc9.dll
The following links in Stock Over Flow also helped me alot in my dilemma:
I'm able to fix the "driver not found" and "connection string is invalid" issues, and here's my current PHP codes:
$db_server = "func.website.com,8787";
//$db_server = "func.website.com:8787\sqlexpress";
$db_database = "db_BreadNButter";
$db_user = "tinapay";
$db_passwd = "p@ssword";
try {
//$db = new PDO ("mssql:host=$db_server;dbname=$db_database;", $db_user, $db_passwd);
$db = new PDO ("sqlsrv:Server=$db_server;Database=$db_database;", $db_user, $db_passwd);
} catch(PDOException $exception) {
die("Unable to open database.<br>Error message:<br><br>$exception.");
}
I think (fingers-crossed) that I already established a connection to MSSQL DBase, but I'm getting the error below:
exception 'PDOException' with message 'SQLSTATE[08001]:
[Microsoft][SQL Server Native Client 11.0]TCP Provider: Timeout error [258].
' in C:\inetpub\wwwroot\breadnbutter\class.connection.php:12 Stack trace: #0
C:\inetpub\wwwroot\breadnbutter\class.connection.php(12):
PDO->__construct('sqlsrv:Server=f...', 'tinapay', 'p@ssword') #1 {main}.
Can anyone enlighten me on why am I getting timeout errors and how can I fix this?
Upvotes: 0
Views: 2142
Reputation: 11
how to connect sqlsrv 2008 in php 5.4.4 erro is: 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
)
)
Upvotes: 1
Reputation: 79
I'm still having problems with this, but I'm able to convince my boss to use asp instead of PHP. thanks a lot for those who helped me out.
Upvotes: 0
Reputation: 31
The port should be func.website.com:8787
. You have a typo with the comma.
Upvotes: 1