ID: 14279
Updated by: zak
Reported By: [EMAIL PROTECTED]
Old Status: Open
Status: Assigned
Old Bug Type: MySQL related
Bug Type: Feature/Change Request
Operating System: Linux-i386
PHP Version: 4.0.6
Old Assigned To: 
Assigned To: zak
New Comment:

Perhaps the code should be changed so that when the 
default connection is closed, the next available 
connection is set as the default.

If no one disagrees, I will do this. However, given that 
the MySQL functions open a connection to localhost if no 
default connection is set, I am changing this from a bug 
to a feature/change request.

Two additional notes on this:

Monty Widenius from MySQL recommends explicitly passing 
the connection handle to mysql_query() -- this helps avoid 
issues like this.

Either change your mysql db auth settings or set your 
default MySQL host in your php.ini file to an invalid 
host. This will prevent you from accidentally connecting 
to a database that you do not wish to connect to.


Previous Comments:
------------------------------------------------------------------------

[2001-11-29 09:01:59] [EMAIL PROTECTED]

We have a PHP script that suddenly changes its connection to a MySQL DB to the MySQL 
DB the localhost has. It wasn't suppose to do so. It happened after we created a new 
connection and then closed this new connection to use the old connection. The problem 
is that PHP now tries to connect to localhost, instead of using the only connection 
available. If it succeeds, it will connect to a host that could have nothing to do 
with the application (imagine a MySQL master-slave environment and the application is 
suppose to connect to the Master and, instead, it connects to the localhost where 
there's a slave and start updating data. This will corrupt the slave machine, which is 
what happened to us)

<?
$conn = mysql_connect("somehost", "user", "passwd");

echo mysql_get_host_info(), "<br>";

$conn2 = mysql_connect("anotherhost", "anotheruser", "anotherpasswd");
mysql_close($conn2);

echo mysql_get_host_info(), "<br>";

?>

Ain't it a good reason for a review in this part of the code?

------------------------------------------------------------------------



Edit this bug report at http://bugs.php.net/?id=14279&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to