Bug #10291: Calling mysql_error() after mysql_connect() does not return the error

From: Date: Wed, 11 Apr 2001 17:10:02 +0000
Subject: Bug #10291: Calling mysql_error() after mysql_connect() does not return the error
Groups: php.dev 
Request: Send a blank email to php-dev+get-51453@lists.php.net to get a copy of this message
From: mfischer@josefine.ben.tuwien.ac.at Operating system: Linux / Debian unstable PHP version: 4.0 Latest CVS (11/04/2001) PHP Bug Type: MySQL related Bug description: Calling mysql_error() after mysql_connect() does not return the error When connecting to a mysql database with the following code : $link = @mysql_connect( 'localhost:/wrong/socket/path', 'user', 'pass'); if( $link == false) { echo "\nerror # ".mysql_errno()." ".mysql_error()."\n"; exit; } PHP of course is unable to successfully connect. PHP fires a warning message that the socket path couldn't be found: MySQL Connection Failed: Can't connect to local MySQL server through socket When using @mysql_connect the warning is does not appear, but its impossible to retrieve the exact error within PHP. mysql_errno() and mysql_error() do not return any information (empty ). Normally on websites, a user doesn't care about the exact error message. But when writing client side Applications (e.g. php-gtk), a call to PHP's mysql_error() or mysql_errno() after mysql_connect() should really return the right message from libmysql. Looking at the current CVS, line 579 in ext/mysql/php_mysql.c retrieves the mysql_error() and fires it as a warning to the user. Since in line 581 the *mysql structure gets freed, Its clear for me that a call in PHP after mysql_connect cannot retrieve this error. Are there any workarounds possible ? Its not a high priority problem of course but seriously to take I guess ? thanks, Markus -- Edit Bug report at: http://bugs.php.net/?id=10291&edit=1

« previous php.dev (#51453) next »