PHP connection sqlserver2008, how to connect the database on the specified IP address

Source: Internet
Author: User
PHP connection sqlserver2008, how to connect the database on the specified IP address
$serverName = "(local)"; Database server address
$uid = "sa"; Database user Name
$pwd = "password123"; Database Password
$connectionInfo = Array ("UID" = = $uid, "PWD" = = $pwd, "Database" = "test");
$conn = Sqlsrv_connect ($serverName, $connectionInfo);
if ($conn = = False)
{
echo "Connection failed! ";
Die (Print_r (Sqlsrv_errors (), true));
}
if ($conn) {
echo "Connected successfully";
}

The connection was successful, but how to change the local to 127.0.0.1.
------Solution--------------------
Switch directly to an IP address
------Solution--------------------
$serverName = "IP Address";
Or
$serverName = "Computer name";
If there are multiple instances on the server, you also need to have the instance name

Remote connection also requires remote connection service
SQL attacks are prevalent due to the default remote connection of SQL Server 2000.
So now all learned, without the cumbersome remote connection authorization, is unable to connect
  • 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.