I want to ask you about how to connect to MSSQL Server 2005 using PHP?
I got error like this :
Connection could not be established. 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 ) )
and here is my PHP code :
<?php
$serverName = "192.168.183.249\MSSQLSERVER, 1542"; //serverName\instanceName, portNumber default is 1433)
$connectionInfo = array( "Database"=>"SEI_AproCS", "UID"=>"sa", "PWD"=>"");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
?>
Please help to advice.
THanks
To connect with sql server you need to add dll file for sql server in the directory
You instal driver. ODBC
link download https://www.microsoft.com/en-us/download/details.aspx?id=36434
good luck
You just need to install driver from this link PHP Driver
You can follow this link for tutorial PHP MSSQL Tutorial
An other option is to connect to mssql using DSN ,
and this easy way you just to enable mssql extension in php
And follow this link to create DSN Create DSN in windows
Also follow this link to connect using php and DSN Connect php using DSN
Try PDO:
I could not get the first line to work due to weird compiler version incompatibilities, but the second one worked fine after installing Microsoft ODBC Driver 11 for SQL Server
PHP Version 5.3.0 has built-in ODBC support, according to
php.ini
, but that still lists an activeextension=php_pdo_odbc.dll
here.