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

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");
$query = "INSERT INTO VALUES('0012', 'Mike's place', 'false')";
$con_id_2 = mysql_connect("localhost", "someuser", "apass");
//abort with 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][/url]
Try a CVS snapshot (php4): [url][/url]
Try a CVS snapshot (php5): [url][/url]
Fixed in CVS: [url][/url]
Fixed in release: [url][/url]
Need backtrace: [url][/url]
Try newer version: [url][/url]
Not developer issue: [url][/url]
Expected behavior: [url][/url]
Not enough info: [url][/url]
Submitted twice: [url][/url]
register_globals: [url][/url]
PHP 3 support discontinued: [url][/url]
Daylight Savings: [url][/url]
IIS Stability: [url][/url]
Install GNU Sed: [url][/url]