An error occurred while connecting to mysql using php.

Source: Internet
Author: User
Php fails to connect to mysql. copy and paste the following code to the conn_mysql.php file, and change "your password" to your mysql password & lt ;? Php $ connectionmysql_connect (& quot; localhost & quot;, & quot; root & quot;, & quot; your password & quot;); mysql_select_db (& quot; m php failed to connect to mysql
Copy the following code and paste it into the conn_mysql.php file. change "your password" to your mysql password.
$ Connection = mysql_connect ("localhost", "root", "your password ");
Mysql_select_db ("mysql ");
If ($ connection ){
Echo "script" alert ('database connection normal '); script ";
}
Else {
Echo "script" alert ('database connection failed, please check if mysqle service is started'); script ";
}
?>

An error occurred after entering http: // 127.0.0.1/conn_mysql.php in the browser.
Show: Not Found

The requested URL/conn_mysql.php was not found on this server.
What is the problem? I am a Cainiao. please let me know.


------ Solution --------------------
The access path is incorrect. Check where conn_mysql.php is stored.
------ Solution --------------------
It must be placed in the root directory.
------ Solution --------------------
Is it in the website directory?
------ Solution --------------------
Create a file in the root directory

Phpinfo ();
?>

Then, check whether it is normal.

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.