From: moa_hunter at yahoo dot com
Operating system: Linux from source, 2.4.21
PHP version: 4.3.2
PHP Bug Type: MySQL related
Bug description: mysql_connect() doesn't set mysql_error() to false on valid connect

Description:
------------
If an error is created by a mysql query, then you try to open a new
database connection, then call mysql_error(), mysql_error() returns the
error from the failed query, not false because the connection was valid.

Having searched through the bug reports, esp 2051, 10291, and 22651, it
seems like mysql_error() should be false from version 4.0.6 onwards.

Reproduce code:
---------------
$connect_id = mysql_connect("localhost","auser","pass");
mysql_select_db("main_student_data");
$query = "INSERT INTO VALUES('0012', 'Mike's place', 'false')";
mysql_query($query);
if(mysql_error())
{
$con_id_2 = mysql_connect("localhost", "someuser", "apass");
if(mysql_error())
{
//abort with error
die(mysql_error());
} else
{
//code to write error to database
//...
}
}

//I know one should check if mysql_connect returns false
//rather than if mysql_error() exists, but this is to show
// what happens.


Expected result:
----------------
For the code under write error to database to be run, because
mysql_error() should be false if the second connection is made.

Actual result:
--------------
The script dies with error:

You have an error in your SQL syntax near 's place', 'false' at line 1

--
Edit bug report at [url]http://bugs.php.net/?id=24689&edit=1[/url]
--
Try a CVS snapshot (php4): [url]http://bugs.php.net/fix.php?id=24689&r=trysnapshot4[/url]
Try a CVS snapshot (php5): [url]http://bugs.php.net/fix.php?id=24689&r=trysnapshot5[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=24689&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=24689&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=24689&r=needtrace[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=24689&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=24689&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=24689&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=24689&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=24689&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=24689&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=24689&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=24689&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=24689&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=24689&r=gnused[/url]