Reputation: 22050
I am using the below code
Php code
$serverName = "serverName\\sqlexpress, 1433"; //serverName\instanceName, portNumber (default is 1433)
$connectionInfo = array( "Database"=>"dbName", "UID"=>"userName", "PWD"=>"password");
$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));
}
Errors
Connection could not be established. Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -49 [code] => -49 [2] => This extension requires the Microsoft ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires the Microsoft ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server 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 ) )
Visited the link - https://www.microsoft.com/en-us/download/confirmation.aspx?id=57163 and downloaded Microsoft Drivers 5.3 for PHP for SQL Server
I am using wamp32, php-5.6.35 connecting to a MSSQL 2012.
PHP INFO sqlsrv support is enabled
I tried using ASPX(NET) but faced a ton of problems so decided to go with PHP.
Any idea on resolving this would be great.
Upvotes: 0
Views: 236
Reputation: 5284
Verify:
ODBC Driver 11 for SQL Server for x86:https://www.microsoft.com/en-us/download/details.aspx?id=36434
For php 5.6 You need to download driver version 3.2 https://learn.microsoft.com/en-us/sql/connect/php/system-requirements-for-the-php-sql-driver?view=sql-server-2017
check if you have php5.dll / php5ts.dll, php_sqlsrv_56_nts.dll, php_sqlsrv_56_ts in your php "ext" folder
Verify if your sql server allows remote connections
Upvotes: 1