From:             craigs at abr dot com dot au
Operating system: Redhat Linux Adv Serv 2.1AS
PHP version:      4.2.3
PHP Bug Type:     MySQL related
Bug description:  mysql_errno/error failing to return a expected error after a failed 
connect

Calling mysql_errno or mysql_error after a failed
mysql_connect when there is an already existing
mysql connection resource does not return any
error message for the failed connect.

According to the doco, it would be expected to return
an error such as 'Unknown Mysql Server Host'.

I have searched the bug database, and bugs
2051 and 10291 report a related issue of mysql_error/errno
not reporting mysql_connect errors, however a review
of the change log reports support for mysql_connect errors
was added in 4.0.6.

A code segment that reproduces this bug follows
========================
$LinkID = mysql_connect("localhost","login","password");
mysql_select_db("mysql");
mysql_query("SELECT * FROM user");


$LinkID2 = mysql_connect("badserver","login","password");
echo "Mysql Error: ".mysql_errno()." - ".mysql_error()."\n";
==================
Expected result- Mysql Error: 2005 - Unknown MySQL Server Host 'badserver'
(1)

Actual Result - Mysql Error: 0 -

Commenting out the first 3 lines and re running the script
returns the expected error of unknown server.

I would guess that the mysql_error functions use of a default
link resource of the last open resource is at fault, as none
is opened in the connect.

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

Reply via email to