Selecting database using alternative methods in PHP

Most of the time we use mysql_select_db() to select a mysql database, the syntax is
mysql_select_db( db_name, connection );
The above syntax results a boolean value, i.e. either true (1) or false(0).

Alternatively, you can use MySQL command:

USE database_name

Let me show you how to use it with PHP. You can implement the above MySQL command as with other MySQL commands

For example,

$query = "USE database_name;";
mysql_query($query, $connection);

This will select the database named database_name.

Was this information helpful. Have you ever used this? Comment here in HackTweaks.com

You can leave a response, or trackback from your own site.

Leave a Reply