ID:               30051
 User updated by:  Nico dot Laus dot 2001 at gmx dot de
 Reported By:      Nico dot Laus dot 2001 at gmx dot de
-Status:           Feedback
+Status:           Closed
 Bug Type:         MySQLi related
 Operating System: Linux 2.6.8.1
 PHP Version:      5.0.1
 New Comment:

ok, I checked with cvs and your example worked, but not my 
script 
-> then I discovered, that there could have been another 
successfull connect and this may be the reason for not 
reporting the failed connection (although I do not really 
understand how this can happen, because the connection 
check does take place directly after connecting) 
I rewrote my script and now it works - so I consider this 
"bug" as closed 
-> thanks for your help


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

[2004-09-11 14:23:50] [EMAIL PROTECTED]

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 
 
 
 

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

[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

Reply via email to