|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32798 mysql_error doesn't work correctly with two mysql_connects
Submitted: 2005-04-22 00:34 UTC Modified: 2005-04-23 19:15 UTC
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: wkonkel at mindshare dot net Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.3.10 OS: FreeBSD
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: wkonkel at mindshare dot net
New email:
PHP Version: OS:


 [2005-04-22 00:34 UTC] wkonkel at mindshare dot net
I have found the same problem as this bogus bug (it's not bogus though):

This is still an issue in 4.3.10 and is not bogus.  You cannot pass $link2 as a parameter to mysql_error becuase upon a failed connection, $link2 is false.  How do you get the errno/error?

Reproduce code:
Scenario 1: 
$link1 = @mysql_connect("localhost","user","pass");
$link2 = @mysql_connect("blah","user","pass") or die("error: " . mysql_errno() . " -- " . mysql_error());

Scenario 2:
//$link1 = @mysql_connect("localhost","user","pass");
$link2 = @mysql_connect("blah","user","pass") or die("error: " . mysql_errno() . " -- " . mysql_error());

Expected result:
Scenario 1:
error: 2005 -- Lost connection to MySQL server during query 

Scenario 2:
error: 2005 -- Lost connection to MySQL server during query 

Actual result:
Scenario 1:
error: 0 -- 

Scenario 2:
error: 2005 -- Lost connection to MySQL server during query 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-22 00:38 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

 [2005-04-23 19:15 UTC]

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Sep 29 13:01:25 2023 UTC