PHP failed to connect to SQL

Source: Internet
Author: User
Code: $DBC = Mysqli_connect (' localhost ', ' Tom ', ' 123123 ', ' aliendatabase ')
Or Die (' Error connecting to MySQL server. ');
Also separates the database one MDF and one LDF file in the same folder.
But the test still went wrong, as if the SQL Server location could not be connected:
Warning:mysqli_connect () [Function.mysqli-connect]: (hy000/2003): Can ' t connect to MySQL server on ' localhost ' (10061) in E:\Learing\phpWeb\aliens\report.php on line 22
Error connecting to MySQL server.
I am using Microsoft SQL Server 2005, my SQL is connected to the server, the user name and password is not wrong. Solving.


Reply to discussion (solution)

You're using Microsoft Microsoft SQL, and you're using mysqli to connect to the connection.
Mssql_connect

Little brother just learned PHP, a lot of do not understand. Trouble the Great God to help me see again, I changed after still is wrong.
$DBC = mysql_connect (' localhost ', ' Tom ', ' 123123 ', ' aliendatabase ')
Or Die (' Error connecting to MySQL server. ');
$query = "INSERT into Aliens_abduction (first_name, last_name, when_it_happened, How_long,".
"How_many, Alien_description, What_they_did, fang_spotted, other, email)".
"VALUES (' $first _name ', ' $last _name ', ' $when _it_happened ', ' $how _long ', ' $how _many ',".
"' $alien _description ', ' $what _they_did ', ' $fang _spotted ', ' $other ', ' $email ')";
$result = mysql_query ($dbc, $query)
Or Die (' Error querying database. ');
Mysql_close ($DBC);

Warning:mysql_connect () [Function.mysql-connect]: Can ' t connect to MySQL server on ' localhost ' (10061) in E:\Learing\phpW eb\aliens\report.php on line 22
Error connecting to MySQL server.

  • 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.