Connecting to MySQL Using PHP
There are two main steps to connecting to a MySQL database using PHP.
First, connect to your MySQL server using the mysql_connect statement. For example:
$con = mysql_connect(‘HOSTNAME’,’USERNAME’,’PASSWORD’);
You can log in to your hosting account manager to find the hostname, user name, and password for your database.
Next, select the database that you want to access using mysql_select_db. For example:
Where “DATABASENAME” is the name of your database. Again, you can log in to your hosting account manager to find the name of your database. The name of your database is usually the same as the user name for that database.
From here, you can query your database using your PHP script.