mysql_select_db()

Once a connection to the database server has been established, a specific database must be selected by passing the database name as the first parameter into the mysql_select_db() function:

 

mysql_select_db( 'databaseName', connectio) ;

 

*Note: If the (optional) second parameter, connection, is omitted, the last opened connection by mysql_connect will be used.

 

<?php
	include('/var/www/dbConfig.php'); //get the db config

	$connection = mysql_connect( $server, $user, $passwd ) ; //connect to the db server

	if( ! $connection ) {

		die('Error connecting to the database:' . mysql_error() ) ;
	}

	mysql_select_db('Academy') ; //select the database to be used

	/* MORE CODE TO BE INSERTED HERE */

	mysql_close( $connection ) ;
?>

 

The database is now ready to be acted upon.

Leave a Reply