I am trying to connect to SQL Server 2008 on machine-1 from PHP code on another machine-2. I am using PHP 5.4.7, XAMPP 1.8.1 and I have copied the sql server dlls into PHP/ext folder and modified the php.ini file.
Now, when I try to connect to SQL server I am getting following error.
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 ) )
My PHP code is as follows -
<?php
//phpinfo();
$server = "sql server\express,1433"; //serverName\instanceName, portNumber (default is 1433)
$uid="username";
$pwd="password";
$connectionInfo = array("UID" => $uid, "PWD" => $pwd, "Database"=>"rod_prd_tmart");
$conn = sqlsrv_connect( $server, $connectionInfo) ;
if($conn)
{
echo "Connection established.\n";
} else
{
echo "Connection could not be established in this text.\n";
die( print_r( sqlsrv_errors(), true));
}
sqlsrv_close( $conn);
?>
Please help me resolve this issue. Thanks.
print_r()output's has carriage returns. You'll see them if you use the "View Source" feature of your browser. - Álvaro González