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.