Quote:
Originally Posted by DarkSlyder
Why does 'mysql_connect' always returns a positive handle with a failed connection? Even 'mysql_errno' doesn't seem to be working.
pawn Код:
//Testing code printf("%d", mysql_connect(SQL_HOST, SQL_USER, "db1", SQL_PWD)); //Correct db printf("%d", mysql_errno()); printf("%d", mysql_connect(SQL_HOST, SQL_USER, "123456", SQL_PWD)); //Invalid db printf("%d", mysql_errno()); printf("%d", mysql_connect(SQL_HOST, SQL_USER, "db2", SQL_PWD)); //Correct db printf("%d", mysql_errno());
Код:
//Output
1
0
2
0
3
0
|
mysql_connect returns the handle id, even if it fails to connect (which would be handled by OnQueryError) the connect function still passes the handle to it. If you put a print in OnQueryError I bet it would pass the proper error number for an invalid DB.