Once you get connection with MySQL server,it is required to select a particular database to work
with. This is because there may be more than one database available with MySQL Server.
This is very simple to select a particular database from mysql> prompt. You can use SQL
command use to select a particular database.
Here is an example to select database called TUTORIALS:
[root@host]# mysql -u root -p
mysql> use TUTORIALS;
Now you have selected TUTORIALS database and all the subsequent operations will be performed on
NOTE: all the database name, table names, table fields name are case sensitive. So you
would have to use prpoer names while giving any SQL command.
PHP provides function mysql_select_db to select a database.It returns TRUE on success or
FALSE on failure.
bool mysql_select_db( db_name, connection );
Here is the example showing you how to select a database.
<title>Selecting MySQL Database</title>
$dbhost = 'localhost:3036';
$dbuser = 'guest';
$dbpass = 'guestpass';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db( 'TUTORIALS' );
Your Query was successfully sent!