Be carefull if you are using two databases on the same server at the same time. By default mysql_connect returns the same connection ID for multiple calls with the same server parameters, which means if you do

You can select MySQL database without using this function.Simply right after connecting to MySQL<?php $connection = mysql_connect("dabatbasehost", "username", "password"); ?>perform this query:<?php mysql_query("USE somedatabase", $connection); ?>

"Sets the current active database on the server that's associated with the specified link identifier. Every subsequent call to mysql_query() will be made on the active database."

The 2nd statement is not true or at best unclear.

mysql_query() manual entry actually correctly states it will use the last link opened by mysql_connect() by default.

Thus if you have 2 connections you will need to specify the connection when calling mysql_query or issue the connect again to ensure the 1st database becomes the default, simply using mysql_select_db will not make the 1st database the default for subsequent calls to mysql_query.

Its probably only apparent when the two databases are on different servers.

Really, this is a mysql specific feature, but worth noting here. So long as the mysql user has been given the right permissions to all databases and tables where data is pulled from or pushed to, this will work. Though the mysql_select_db function selects one database, the mysql statement may reference another (the syntax for referencing a field in another db table being 'database.table.field').

Problem with connecting to multiple databases within the same server is that every time you do:mysql_connect(host, username, passwd);it will reuse 'Resource id' for every connection, which means you will end with only one connection reference to avoid that do:mysql_connect(host, username, passwd, true);keeps all connections separate.