How to make connection with mysql

Suppose you have mysql and php installed, also you they both are interacting with each other then here is the connection file that u have to made in order to interact with the database of mysql.

$host="localhost"; \\ if the database you want to interact is on your pc.

$user="root"; \\ mysql username, by default is root

$pass="yourpassword"; \\ pass of mysql, if there is no password then $pass="";


mysql_connect("$host","$user","$pass") or die("cannot connect to the database server");

mysql_select_db("$db_name") or die("cannot select the database");

save this in any file, such as conn.php and include in every file over which u want database interaction.