Use the following code in php to connect and test _ PHP Tutorial

Source: Internet
Author: User
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...

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.