note 115642 added to function.mysql-error

From: Date: Sat, 30 Aug 2014 21:30:13 +0000
Subject: note 115642 added to function.mysql-error
Groups: php.notes 
Request: Send a blank email to php-notes+get-200346@lists.php.net to get a copy of this message
The following code returns two times the same error, even though I would have expected only one: $ conn = mysql_connect ('localhost', 'root', ''); $ conn2 = mysql_connect ('localhost', 'root', ''); mysql_select_db ('db1', $ conn); mysql_select_db ('db2', $ conn2); $ result = mysql_query ("select 1 from dual", $ conn); $ result2 = mysql_query ("select 1 from luad", $ conn2); echo mysql_error ($ conn) "<hr>". echo mysql_error ($ conn2) "<hr>". The reason for this is that mysql_connect not working as expected a further connection returns. Since the parameters are equal, a further reference to the previous link is returned. So also changes the second mysql_select_db the selected DB of $conn to 'db2'. If you change the connection parameters of the second connection to 127.0.0.1, a new connection is returned. In addition to the parameters new_link the mysql_connect() function to be forced. ---- Server IP: 72.52.91.14 Probable Submitter: 79.208.247.170 ---- Manual Page -- http://php.net/manual/en/function.mysql-error.php Edit -- https://master.php.net/note/edit/115642 Del: integrated -- https://master.php.net/note/delete/115642/integrated Del: useless -- https://master.php.net/note/delete/115642/useless Del: bad code -- https://master.php.net/note/delete/115642/bad+code Del: spam -- https://master.php.net/note/delete/115642/spam Del: non-english -- https://master.php.net/note/delete/115642/non-english Del: in docs -- https://master.php.net/note/delete/115642/in+docs Del: other reasons-- https://master.php.net/note/delete/115642 Reject -- https://master.php.net/note/reject/115642 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#200346) next »