ID: 10291
User Update by: [EMAIL PROTECTED]
Status: Open
Bug Type: MySQL related
Description: Calling mysql_error() after mysql_connect() does not return the error

Maybe I should add that I've actually also read closed bug report # 2051 about that 
topic.

Zeev answered that in this situation mysql_error() never has and doesn't return error 
information for failed connections.

But libmysql is returning the right (and indeed very
descriptive) error message.

I hope the upcoming demand for client side php application convinces Zeev.


Previous Comments:
---------------------------------------------------------------------------

[2001-04-11 13:10:02] [EMAIL PROTECTED]
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

---------------------------------------------------------------------------


Full Bug description available at: http://bugs.php.net/?id=10291


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to