[ Team LiB ] Previous Section Next Section

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, which requires a database name and optionally accepts a link resource. If you omit this, the resource returned from the last connection to the server is 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 p24:


$database = "p24";
mysql_select_db( $database ) or die ( "Couldn't open $database );


    [ Team LiB ] Previous Section Next Section