#40588 [NEW]: mysqli_connect_error() == "" on error

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #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

  2. Similar Questions and Discussions

    1. #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...
    2. #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: ...
    3. "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...
    4. 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"...
    5. #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...
  3. #2

    Default #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

  4. #3

    Default #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

  5. #4

    Default #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

  6. #5

    Default #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

  7. #6

    Default #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 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.


    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

  8. #7

    Default #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 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]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

  9. #8

    Default #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.
    >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]tony2001@php.net[/email]
    >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]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

  10. #9

    Default #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.
    >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.

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

    [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 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]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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139