PhpDig.net

PhpDig.net (http://www.phpdig.net/forum/index.php)
-   Bug Tracker (http://www.phpdig.net/forum/forumdisplay.php?f=27)
-   -   Strange db change behavior [Fix included] (http://www.phpdig.net/forum/showthread.php?t=2487)

shockfreezer 06-22-2006 07:11 AM

Strange db change behavior [Fix included]
 
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:
PHP Code:

$id_connect = @mysql_connect(PHPDIG_DB_HOST,PHPDIG_DB_USER,PHPDIG_DB_PASS); 

to:
PHP Code:

$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. :)

Greez
shockfreezer


All times are GMT -8. The time now is 02:48 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.