bigmac90 Posted August 7, 2013 Share Posted August 7, 2013 I wonder if anyone can help me. I'm creating an application in PHP and am using a SQL server database on my local computer to develop the application. The only problem is I cannot connect to the database. My code looks like <?php $serverName = "LIAMJAY-PC\SQLEXPRESS"; //serverName\instanceName $connectionInfo = array( "Database"=>"ONEDB"); $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)); } ?> to connect to the database. However, everytime I run the code I keep getting a 18456 error code. Does anybody know what my problem is and if so, what is the solution??? Quote Link to comment https://forums.phpfreaks.com/topic/280915-cannot-connect-to-sql-server-on-local-machine-using-php/ Share on other sites More sharing options...
Boxerman Posted August 7, 2013 Share Posted August 7, 2013 $server = 'LIAMJAY-PC\SQLEXPRESS'; $link = mssql_connect($server, 'username', 'password'); if (!$link) { die(print_r( sqlsrv_errors(), true)); } Try that, not tested. Quote Link to comment https://forums.phpfreaks.com/topic/280915-cannot-connect-to-sql-server-on-local-machine-using-php/#findComment-1443830 Share on other sites More sharing options...
kicken Posted August 7, 2013 Share Posted August 7, 2013 Google knows if you just search the error code: http://blogs.msdn.com/b/sql_protocols/archive/2006/02/21/536201.aspx Quote Link to comment https://forums.phpfreaks.com/topic/280915-cannot-connect-to-sql-server-on-local-machine-using-php/#findComment-1443887 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.