Selecting a Database
Now that we have established a connection to the MySQL daemon, we must choose which database we want to work with. You can select a database with the mysql_ select_db() function. mysql_select_db() requires a database name and optionally accepts a link resource. If you omit this, the resource returned from the last connection to the server will be assumed. mysql_select_db() returns true if the database exists and you are able to access it. In the following fragment, we select a database called sample.
$database = "sample"; mysql_select_db( $database ) or die ( "Couldn't open $database );