A call to mysql_query() without a connection parameter will use the last connection. So while you only connect to one database, you will not see any problems.
From documents :
If no link identifier is specified, the last link assumed by mysql_connect () is assumed. If no such link is found, it will try to create one as if mysql_connect () was called without arguments. If the connection is not found or not established, an error of level E_WARNING is generated.
If you add or include some new code that connects to another database, for example, perhaps a track detector or analytics tool, this may violate the existing code because it establishes a different mysql connection - and any of your queries that occur after a new connection is established will now use the wrong connection.
This will happen even if the additional code is correctly written and will always use its own connection identifier - it will not have problems with accidentally using your connection, but your code will still accidentally use its connection.
To use mysql_query() , you really need to track the database connection and use it in every query.
All of the above - if you make changes to all mysql_* calls mysql_* , go to mysqli , mysql_* functions are mysql_* and are no longer supported . The mysqli extension can be almost a replacement for replacement, and also provides support for features such as prepared statements.
The PDO extension is another possible replacement, but switching from mysql_* will require a bit more rewriting.
source share