View Full Version : Strange db change behavior [Fix included]

06-22-2006, 08:11 AM
Hi there,

I use a customized script to search with phpDig, that means I include the config of phpDig into my own script and use the functions of "/libs/search_functions" to search with.

The problem of this method is that phpDig's connect to the MySQL server changes the db of my own script. If there are other db-queries after the phpDig search the queries would go to the phpDig db and not to the db of the including script.
This behavior causes in the connection handling of php, if a connection with the same authorisation data would be etablished it changes only the db and generates not a new connection.

To prevent this change the connection code in the file "/includes/connect.php" on line 30, from:
$id_connect = @mysql_connect(PHPDIG_DB_HOST,PHPDIG_DB_USER,PHPDIG_DB_PASS);
$id_connect = @mysql_connect(PHPDIG_DB_HOST,PHPDIG_DB_USER,PHPDIG_DB_PASS,true);

This additional parameter forces php to create a new connection. So you can be sure there is no db-change for your own script. :)