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:
- Connect to SQL Server through PDO using SQL Server Driver
- Error connecting to MSSQL with SQLSrv and PHP 5.4.7
- How can I connect to Sql Server from a Mac with PHP PDO?
- Connecting to mssql using pdo through php and linux
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?
"; die(); }` I'm still getting the same error: `SQLSTATE[08001]: [Microsoft][SQL Server Native Client 11.0]TCP Provider: Timeout error [258]` – thedevgypsy Mar 28 '14 at 11:02