ID: 40588
User updated by: frankpw at fw2s dot com
Reported By: frankpw at fw2s dot com
-Status: Bogus
+Status: Open
Bug Type: MySQLi related
Operating System: Win XP Pro
PHP Version: 5.2.1
New Comment:
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?
Previous Comments:
------------------------------------------------------------------------
[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.
------------------------------------------------------------------------
[2007-02-22 10:59:27] [EMAIL PROTECTED]
Cannot reproduce.
Make sure the client library is of the same version is the MySQL
server.
------------------------------------------------------------------------
[2007-02-22 04:45:41] frankpw at fw2s dot com
Description:
------------
In my class I'm opening a connection with mysqli_connect().
mysqli_connect_error() returns description of any error except one. If
one parameter is of wrong type (i.e port as string rather than
numeric).
Reproduce code:
---------------
public function OpenConnection($host, $user, $pass, $name = null,
$port = null, $sock = null, $chrs = null)
{
$this->mysqli = @mysqli_connect($host, $user, $pass, $name, $port,
$sock);
if (empty($this->mysqli)) die ("Execution stopped! " .
mysqli_connect_error() . "<br />\n");
if (!empty($chrs)) $this->DefaultCharacterSet($chrs);
}
Expected result:
----------------
"Execution stopped! mysqli_connect expects parameter 5 to be long,
string given"
Actual result:
--------------
"Execution stopped!"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40588&edit=1