|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-12-02 03:06 UTC] zak@php.net
[2001-12-02 17:08 UTC] zak@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 19:00:01 2025 UTC |
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?