ID:               45940
 Comment by:       mudroeb at gmail dot com
 Reported By:      talmage dot news at gmail dot com
 Status:           Assigned
 Bug Type:         MySQLi related
 Operating System: Centos 5
 PHP Version:      5.2.6
 Assigned To:      mysql
 New Comment:

Get the same problem but make investigation:

$mysqli = new mysqli("localhost:3307", "my_user", "my_password",
"world");
-> got error

$mysqli = new mysqli("127.0.0.1:3307", "my_user", "my_password",
"world");
-> got error

BUT!:
$mysqli = new mysqli("127.0.0.1:3306", "my_user", "my_password",
"world");
-> change server port to default (3306).

$mysqli = new mysqli("localhost", "my_user", "my_password",
"world");
-> all works correct. 
Seems that variable not parsed for $HOST_NAME and $PORT_NUMBER and
function try to connect using incorrect (not parsed) string.


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

[2008-08-29 11:51:21] [EMAIL PROTECTED]

I can reproduce that, assigning to mysql folks.

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

[2008-08-29 03:59:12] talmage dot news at gmail dot com

Upgrading to snap did not fix.


[EMAIL PROTECTED] src]# /usr/local/php/bin/php -v
PHP 5.2.7-dev (cli) (built: Aug 28 2008 20:54:37) 
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
[EMAIL PROTECTED] src]# /usr/local/php/bin/php -q test.php

Warning: mysqli::mysqli(): (HY000/2005): Unknown MySQL server host
'127.0.0.1:3307' (3) in /srv/php/projects/test/src/test.php on line 4

Warning: main(): Couldn't fetch mysqli in
/srv/php/projects/test/src/test.php on line 7

Warning: main(): Couldn't fetch mysqli in
/srv/php/projects/test/src/test.php on line 12
Host information: 

Warning: mysqli::close(): Couldn't fetch mysqli in
/srv/php/projects/test/src/test.php on line 15
[EMAIL PROTECTED] src]#

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

[2008-08-28 21:13:13] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi



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

[2008-08-28 05:26:07] talmage dot news at gmail dot com

Description:
------------
The documentation at:

http://us.php.net/manual/en/mysqli.connect.php

Provides an example for the OO method of constructing a MySQLI instance
and checking for error.

However, when testing this example and forcing an error the output is
not as the documentation describes (which as documented is the way I
would expect the OO library to behave.)


I first noticed this behavior on a PHP 5.2.3 install on my Centos
server. I then tried the same thing on a Debian box on 5.2.3 and
received the same unexpected behavior.


I then downloaded and compiled PHP 5.2.6 on my Centos box and still
received the unexpected behavior.

Reproduce code:
---------------
<?php

/* Force an error -> 3307 is not where mysql is listening */
$mysqli = new mysqli("127.0.0.1:3307", "my_user", "my_password",
"world");

/* Check for error: This should return true and enter the if block */
if ($mysqli->connect_error) {
    printf("Connect failed: %s\n", $mysqli->connect_error);
    exit();
}

printf("Host information: %s\n", $mysqli->host_info);

/* close connection */
$mysqli->close();
?>

Expected result:
----------------
Connect failed: Unknown MySQL server host '127.0.0.1:3307'

Actual result:
--------------
Warning: mysqli::mysqli(): (HY000/2005): Unknown MySQL server host
'127.0.0.1:3307' (3) in /srv/php/projects/test/src/test.php on line 4

Warning: main(): Couldn't fetch mysqli in
/srv/php/projects/test/src/test.php on line 7

Warning: main(): Couldn't fetch mysqli in
/srv/php/projects/test/src/test.php on line 12
Host information: 

Warning: mysqli::close(): Couldn't fetch mysqli in
/srv/php/projects/test/src/test.php on line 15


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


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

Reply via email to