ID:               40588
 Updated by:       [EMAIL PROTECTED]
 Reported By:      frankpw at fw2s dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         MySQLi related
 Operating System: Win XP Pro
 PHP Version:      5.2.1
 New Comment:

That's easy - "3306" and "10" are numeric strings, but "abcd" is not.

>Isn't it logical to assume that if connection fails
That's the point. Connection doesn't fail. 
The function is called with wrong parameters, so it doesn't even _try_
to connect, because we already know the parameters are wrong.
You can see the same with mysqli_connect() without any parameters.


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

[2007-02-22 20:19:25] frankpw at fw2s dot com

I promise to end this discussion if you tell me that passing port
number as "3306" or "10" (notice quotes) is correct. Port is declared
as int not a string. With above values "3306" will make connection
(assuming that server is set to listen on port 3306) and with "10" will
fail with proper values returned by mysqli_connect_errno and
mysqli_connect_error. Isn't it logical to assume that if connection
fails (for whatever reason) this reason should be consistently stated
in responses from mysqli_connect_errno() and mysqli_connect_error()?

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

[2007-02-22 19:55:18] [EMAIL PROTECTED]

>This check fails in this particular case 

This check should be used when you pass correct parameters to the
function.

>Are you insisting that this is not connection error and 
>that it shoud be handled differently?

Yes, I do.
You're passing wrong parameters to the function. 

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

[2007-02-22 19:42:42] frankpw at fw2s dot com

That is not a point. Even the manual shows how connection errors should
be handled:
/* check connection */ 
if (mysqli_connect_errno()) {
   printf("Connect failed: %s\n", mysqli_connect_error());
   exit();
}
This check fails in this particular case because mysqli_connect_error()
is empty and mysqli_connect_errno is 0. Are you insisting that this is
not connection error and that it shoud be handled differently?

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

[2007-02-22 19:02:51] [EMAIL PROTECTED]

Remove the @, you'll see the error.

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

[2007-02-22 18:34:44] frankpw at fw2s dot com

Additional info:
Server info: 5.0.27-community-max-nt
Client info: 5.0.22
That's as close to match server and client versions as it gets. I've
downloaded php_mysql.dll and php_mysqli.dll for server version 5.0.27
directly from MySQL. Please try the code below:
<?php
$mysqli = @mysqli_connect("localhost","root","pass",null,"abcd");
if (empty($mysqli)) die ("Connection attempt failed! " .
mysqli_connect_error() . "<br />\n");
echo "Connected!<br />\n";
echo "Host info: " . mysqli_get_host_info($mysqli) . "<br />\n";
echo "Client info: " . mysqli_get_client_info() . "<br />\n";
echo "Server info: " . mysqli_get_server_info($mysqli) . "<br />\n";
echo "Protocol version: " . mysqli_get_proto_info($mysqli) . "<br
/>\n";
?>
For test purposes make sure that first four parameters are correct and
use fifth as is. Repeat the test with "@" removed from the call to
mysqli_connect(). You'll see that warning is being displayed but
mysqli_connect_error() is empty and mysqli_connect_errno() == 0.

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/40588

-- 
Edit this bug report at http://bugs.php.net/?id=40588&edit=1

Reply via email to