Use the following code in php to connect and test the connection. Copy the code as follows :? Php $ myServerlocalhost; host $ myUsersa; username $ myPasspassword; password $ myDBNorthwind ;? MSSQL database name $ s @ mssql_connect ($ myServer, $ my
The code is as follows:
$ MyServer = "localhost"; // host
$ MyUser = "sa"; // User name
$ MyPass = "password"; // password
$ MyDB = "Northwind ";? // MSSQL database name
$ S = @ mssql_connect ($ myServer, $ myUser, $ myPass)
Or die ("Couldn't connect to SQL Server on $ myServer ");
$ D = @ mssql_select_db ($ myDB, $ s)
Or die ("Couldn't open database $ myDB ");
$ Query = "SELECT TitleOfCourtesy +'' + FirstName + ''+ LastName AS Employee ";
$ Query. = "FROM Employees ";
$ Query. = "WHERE Country = 'USA' AND Left (HomePhone, 5) = '(206 )'";
$ Result = mssql_query ($ query );
$ NumRows = mssql_num_rows ($ result );
Echo "". $ numRows. "Row". ($ numRows = 1? "": "S"). "Returned ";
While ($ row = mssql_fetch_array ($ result ))
{
Echo"
". $ Row [" Employee "]."";
}
The http://www.bkjia.com/PHPjc/318889.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/318889.htmlTechArticle code is as follows :? Php $ myServer = "localhost"; // host $ myUser = "sa"; // username $ myPass = "password"; // password $ myDB = "Northwind ";? // MSSQL database name $ s = @ mssql_connect ($ myServer, $ my...