Select Database
After we have establish the connection in MySQL server, we have to select a database. To do that we are going to use the mysql_select_db() function.
Syntax:
mysql_select_db(databasename,connection)
Parameter:
databasename – the database name you want to use.
connection – Specifies the MySQL connection
Example script:
<?php $conn = mysql_connect("localhost","root","") or die("could not connect"); @mysql_select_db("employee",$conn) or die("could not select database!"); ?>
In our example we have first establish a connection in our MySQL server. Then we have selected the database employee (the name of our database) using the mysql_select_db() function. The die statement will be executed if the connection fails.