Ask a Question related to PHP Bugs, Design and Development.
-
frankpw at fw2s dot com #1
#40588 [NEW]: mysqli_connect_error() == "" on error
From: frankpw at fw2s dot com
Operating system: Win XP Pro
PHP version: 5.2.1
PHP Bug Type: MySQLi related
Bug description: mysqli_connect_error() == "" on error
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 bug report at [url]http://bugs.php.net/?id=40588&edit=1[/url]
--
Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40588&r=trysnapshot44[/url]
Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40588&r=trysnapshot52[/url]
Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40588&r=trysnapshot60[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40588&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=40588&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=40588&r=needtrace[/url]
Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40588&r=needscript[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=40588&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=40588&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=40588&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=40588&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=40588&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=40588&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40588&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=40588&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=40588&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40588&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=40588&r=float[/url]
No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40588&r=nozend[/url]
MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40588&r=mysqlcfg[/url]
frankpw at fw2s dot com Guest
-
#37773 [Asn->Csd]: iconv_substr() gives "Unknown error" when string length = 1"
ID: 37773 Updated by: iliaa@php.net Reported By: dave at dgx dot cz -Status: Assigned +Status: Closed Bug Type: ICONV... -
#37773 [Ver->Asn]: iconv_substr() gives "Unknown error" when string length = 1"
ID: 37773 Updated by: tony2001@php.net Reported By: dave at dgx dot cz -Status: Verified +Status: Assigned Bug Type: ... -
"Error Creating Control" and "Cast from String"
I'm creating a custom date control. In appearance, it's just a textbox and a button. It has three custom properties: CalDate, CalDateType and... -
Acrobat Form Submit error: changes VALUE="true" to "0"
I wrote an HTML page with a form. In the form I had many inputs as in: <INPUT TYPE="radio" NAME="Q1" VALUE="true"> and <INPUT TYPE="radio"... -
#12029 [Com]: "--with-apxs" can cause the error "MySQL: Unable to save result set in"
ID: 12029 Comment by: sietzepost at streetwisedd dot nl Reported By: root at byone dot com Status: Bogus Bug... -
tony2001@php.net #2
#40588 [Opn->Fbk]: mysqli_connect_error() == "" on error
ID: 40588
Updated by: [email]tony2001@php.net[/email]
Reported By: frankpw at fw2s dot com
-Status: Open
+Status: Feedback
Bug Type: MySQLi related
Operating System: Win XP Pro
PHP Version: 5.2.1
New Comment:
Cannot reproduce.
Make sure the client library is of the same version is the MySQL
server.
Previous Comments:
------------------------------------------------------------------------
[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 [url]http://bugs.php.net/?id=40588&edit=1[/url]
tony2001@php.net Guest
-
frankpw at fw2s dot com #3
#40588 [Fbk->Opn]: mysqli_connect_error() == "" on error
ID: 40588
User updated by: frankpw at fw2s dot com
Reported By: frankpw at fw2s dot com
-Status: Feedback
+Status: Open
Bug Type: MySQLi related
Operating System: Win XP Pro
PHP Version: 5.2.1
New Comment:
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,"ab cd");
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.
Previous Comments:
------------------------------------------------------------------------
[2007-02-22 10:59:27] [email]tony2001@php.net[/email]
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 [url]http://bugs.php.net/?id=40588&edit=1[/url]
frankpw at fw2s dot com Guest
-
tony2001@php.net #4
#40588 [Opn->Bgs]: mysqli_connect_error() == "" on error
ID: 40588
Updated by: [email]tony2001@php.net[/email]
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:
Remove the @, you'll see the error.
Previous Comments:
------------------------------------------------------------------------
[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,"ab cd");
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]tony2001@php.net[/email]
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 [url]http://bugs.php.net/?id=40588&edit=1[/url]
tony2001@php.net Guest
-
frankpw at fw2s dot com #5
#40588 [Bgs->Opn]: mysqli_connect_error() == "" on error
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]tony2001@php.net[/email]
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,"ab cd");
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]tony2001@php.net[/email]
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 [url]http://bugs.php.net/?id=40588&edit=1[/url]
frankpw at fw2s dot com Guest
-
tony2001@php.net #6
#40588 [Opn->Bgs]: mysqli_connect_error() == "" on error
ID: 40588
Updated by: [email]tony2001@php.net[/email]
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:
This check should be used when you pass correct parameters to the>This check fails in this particular case
function.
Yes, I do.>Are you insisting that this is not connection error and
>that it shoud be handled differently?
You're passing wrong parameters to the function.
Previous Comments:
------------------------------------------------------------------------
[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]tony2001@php.net[/email]
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,"ab cd");
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]tony2001@php.net[/email]
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 [url]http://bugs.php.net/?id=40588&edit=1[/url]
tony2001@php.net Guest
-
frankpw at fw2s dot com #7
#40588 [Bgs->Opn]: mysqli_connect_error() == "" on error
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:
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()?
Previous Comments:
------------------------------------------------------------------------
[2007-02-22 19:55:18] [email]tony2001@php.net[/email]
This check should be used when you pass correct parameters to the>This check fails in this particular case
function.
Yes, I do.>Are you insisting that this is not connection error and
>that it shoud be handled differently?
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]tony2001@php.net[/email]
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,"ab cd");
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]tony2001@php.net[/email]
Cannot reproduce.
Make sure the client library is of the same version is the MySQL
server.
------------------------------------------------------------------------
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
[url]http://bugs.php.net/40588[/url]
--
Edit this bug report at [url]http://bugs.php.net/?id=40588&edit=1[/url]
frankpw at fw2s dot com Guest
-
tony2001@php.net #8
#40588 [Opn->Bgs]: mysqli_connect_error() == "" on error
ID: 40588
Updated by: [email]tony2001@php.net[/email]
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.
That's the point. Connection doesn't fail.>Isn't it logical to assume that if connection fails
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]tony2001@php.net[/email]
This check should be used when you pass correct parameters to the>This check fails in this particular case
function.
Yes, I do.>Are you insisting that this is not connection error and
>that it shoud be handled differently?
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]tony2001@php.net[/email]
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,"ab cd");
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
[url]http://bugs.php.net/40588[/url]
--
Edit this bug report at [url]http://bugs.php.net/?id=40588&edit=1[/url]
tony2001@php.net Guest
-
frankpw at fw2s dot com #9
#40588 [Bgs]: mysqli_connect_error() == "" on error
ID: 40588
User updated by: frankpw at fw2s dot com
Reported By: frankpw at fw2s dot com
Status: Bogus
Bug Type: MySQLi related
Operating System: Win XP Pro
PHP Version: 5.2.1
New Comment:
As promised I'm not attempting to continue, therfore I didn't change
status to open. And you don't have to answer this. It would be much
easier for me to accept a statement: "I like it the way it is so don't
bother to report this as an error.". It doesn't matter if
mysqli_connect() attempts a connection or not. This attempt is made by
a developer, programmer or whoever is using this function, and,
according to documentation, expecting to get a promised response - if
connection was made then no error, if connection wasn't made, then
error is being reported, like any other. If your arguments are valid
then why do we need error handling at all. I think we are from totally
different schools of logic. Your logic allows three values: false,
true, and something in between.
Best regards,
Frank P. Walentynowicz
Previous Comments:
------------------------------------------------------------------------
[2007-02-22 20:27:40] [email]tony2001@php.net[/email]
That's easy - "3306" and "10" are numeric strings, but "abcd" is not.
That's the point. Connection doesn't fail.>Isn't it logical to assume that if connection fails
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.
------------------------------------------------------------------------
[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]tony2001@php.net[/email]
This check should be used when you pass correct parameters to the>This check fails in this particular case
function.
Yes, I do.>Are you insisting that this is not connection error and
>that it shoud be handled differently?
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]tony2001@php.net[/email]
Remove the @, you'll see the error.
------------------------------------------------------------------------
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
[url]http://bugs.php.net/40588[/url]
--
Edit this bug report at [url]http://bugs.php.net/?id=40588&edit=1[/url]
frankpw at fw2s dot com Guest



Reply With Quote

