ID: 30051 Updated by: [EMAIL PROTECTED] Reported By: Nico dot Laus dot 2001 at gmx dot de -Status: Open +Status: Feedback Bug Type: MySQLi related Operating System: Linux 2.6.8.1 PHP Version: 5.0.1 New Comment:
Please try using this CVS snapshot: http://snaps.php.net/php5-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php5.0-win32-latest.zip this script works fine for me: <?php $mysqli = @new mysqli("localhost", "nonexistentuser", "foo", "test"); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); } $mysqli->connect("localhost", "root", "", "test"); if (!mysqli_connect_errno()) { printf("%s\n", $mysqli->server_info); $mysqli->close(); } ?> Output: Connect failed: Access denied for user 'nonexistentuser'@'localhost' (using password: YES) 5.0.2-alpha-debug-log Previous Comments: ------------------------------------------------------------------------ [2004-09-10 16:13:14] Nico dot Laus dot 2001 at gmx dot de Description: ------------ given the example below from the mysqli documentation, I tried to connect to my MySQL server with wrong data to see, what happens, if the connection really fails. unfortunately the constructor does trigger a WARNING itself and does not return FALSE, as documented. The mysqli_connect_errno() does only return 0 and even the $mysqli->errno variable does not have any value. So I cannot find out, if the connect really has failed or not. I'm using MySQL 4.1.4 Reproduce code: --------------- $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } Expected result: ---------------- Connect failed: <error> Actual result: -------------- ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30051&edit=1