PHP and SQLServer connection


I'm trying to make a connection to SQLServer and PHP But the page gives me the following error:

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server:\SRVDOC\DOCSYSTEMSCAN in C:\wamp\www\conexao.php on line 2

Warning: mssql_select_db() expects parameter 2 to be resource, boolean given in C:\wamp\www\conexao.php on line 3

The current code is:

    $con = mssql_connect("\SRVDOC\DOCSYSTEMSCAN", "sa", "minhasenha");
    mssql_select_db("fd_585b0f87", $con);

I'm racking my brain but I don't know what it could be… Any suggestions? Thanks.


Friend, try to follow the model proposed on the official PHP manual page:

$serverName = "SRVDOC\DOCSYSTEMSCAN"; //serverName\instanceName
$connectionInfo = array( "Database"=>"fd_585b0f87", "UID"=>"sa", "PWD"=>"minhasenha");
$conn = sqlsrv_connect( $serverName, $connectionInfo);


Or try that way with the "mssql_connect" function

$link = mssql_connect($server, 'sa', 'minhasenha');


Good luck!

Scroll to Top