php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50992 Database connect error
Submitted: 2010-02-10 12:19 UTC Modified: 2010-02-10 12:32 UTC
From: gert-rainer dot bitterlich at ima-dresden dot de Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.3.1 OS: Windows 7 64bit
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gert-rainer dot bitterlich at ima-dresden dot de
New email:
PHP Version: OS:

 

 [2010-02-10 12:19 UTC] gert-rainer dot bitterlich at ima-dresden dot de
Description:
------------
The connect to the MySQL database (V5.1.x) faild with PHP 5.3.1 (also with PHP 5.3.2RC1), when I use a real servername, like localhost or the PC name. If I use the IP address it works fine.
With PHP 5.3.0 it was OK.

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

$sHost = 'localhost';
echo'<pre>Host = '.$sHost.'</pre>';

$link = mysqli_init();
if (!$link) {
    die('mysqli_init failed');
}

if (!mysqli_options($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT = 0')) {
    die('Setting MYSQLI_INIT_COMMAND failed');
}

if (!mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 5)) {
    die('Setting MYSQLI_OPT_CONNECT_TIMEOUT failed');
}

if (!mysqli_real_connect($link, $sHost, 'root', 'xitami', 'kb_globals')) {
    die('Connect Error (' . mysqli_connect_errno() . ') '
            . mysqli_connect_error());
}

echo 'Success... ' . mysqli_get_host_info($link) . "\n";

mysqli_close($link);
?>


Expected result:
----------------
Host = localhost
Success... localhost via TCP/IP 

Actual result:
--------------
Host = localhost

Warning: mysqli_real_connect() [function.mysqli-real-connect]: [2002] Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle na (trying to connect via tcp://localhost:3306) in D:\Inetpub\wwwroot\php\test\test_mysqli.php on line 20

Warning: mysqli_real_connect() [function.mysqli-real-connect]: (HY000/2002): Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle nach einer bestimmten Zeitspanne nicht richtig reagiert hat, oder die hergestellte Verbindung war fehlerhaft, da der verbundene Host nicht reagiert hat. in D:\Inetpub\wwwroot\php\test\test_mysqli.php on line 20
Connect Error (2002) Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle nach einer bestimmten Zeitspanne nicht richtig reagiert hat, oder die hergestellte Verbindung war fehlerhaft, da der verbundene Host nicht reagiert hat. 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-10 12:32 UTC] johannes@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

There's nothing we can do. Please use 127.0.0.1 or configure your systme to use IPv4 127.0.0.1, not IPv6 [::1] for localhost.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 12:01:27 2024 UTC