ID:               41407
 Updated by:       [EMAIL PROTECTED]
 Reported By:      david at ols dot es
-Status:           Assigned
+Status:           Wont fix
 Bug Type:         MySQL related
 Operating System: any
 PHP Version:      4.4.7
 Assigned To:      georg
 New Comment:

This change would break BC.


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

[2007-05-16 07:51:36] david at ols dot es

Description:
------------
mysql_errno/mysql_error return valid results on connection failures,
but if you try to connect to a second server while the connection to the
first one is opened, then they return null results, which is ok, as per
doc, the error given is for the last opened connection and not for the
last performed mysql operation. I've seen other "bugs" like this closed
as bogus because the documentation says what it says but what's really
bogus is the current mysql_error/errno implementation. This makes
mysql_error/errno not only unuseful in that situations but also makes it
behave differently from what it does in another laguages (where is
always possible to retrieve error information on connect failures). To
be able to catch this errors (as in any other language),
mysql_error/errno should report the status of the last mysql operation
when no link identifier is given and not report the result of the last
operation on the last opened connection. This will be easy to implement
by just storing error information when any mysql functions fails.


Reproduce code:
---------------
$host = "localhost";  $user = "bogus";  $pw   = "foo";

$conn = mysql_connect($host, $user, $pw);

echo "MySQL status: (".  mysql_errno().": '".mysql_error()."')<BR>";

$host = "localhost";  $user = "user_ok";  $pw   = "pass_ok";

$conn = mysql_connect($host, $user, $pw);

echo "MySQL status: (".  mysql_errno().": '".mysql_error()."')<BR>";

$host = "localhost";  $user = "bogus";  $pw   = "foo";

$conn = mysql_connect($host, $user, $pw);

echo "MySQL status: (".  mysql_errno().": '".mysql_error()."')<BR>";


Expected result:
----------------
first connection failed, error reported ok
second connection succed
third connection failed, error reported ok

Actual result:
--------------
first connection failed, error reported ok
second connection succed
third connection failed, error not reported


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


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

Reply via email to