The code is like this:
$link=mysql_connect("localhost","root","123456");
if(!$link) echo "No connection successful !";
else echo "Connection successful!";
?>
The red part can be modified according to your actual situation.
localhost: Indicates the location of the database. If it is the local machine, write localhost. If it is on another machine, write the IP address.
root: user name to enter the database. MySQL default user name is root.
123456: The password corresponding to the username. Modify this string of numbers according to the administrator password you set.
Of course, the codes mentioned above can only run successfully after configuring Apache + MySQL + PHP. Please pay attention.
Author: Sunec
Original Published by: Cenus Blog
All rights reserved. When reprinting, the author, original source and this statement must be indicated in the form of a link.