php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50263 mysql_connect does not accept localhost
Submitted: 2009-11-22 18:13 UTC Modified: 2009-11-22 18:17 UTC
From: dominique at ottello dot net Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.3.1 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dominique at ottello dot net
New email:
PHP Version: OS:

 

 [2009-11-22 18:13 UTC] dominique at ottello dot net
Description:
------------
Hello,

mysql_connect does not works if host is localhost, correct if host is 127.0.0.1

In the exemple below :
$db_host = "localhost"; //Does not work
$db_host = "127.0.0.1"; //Works

No problem with version 5.3.0.

Best regards

Reproduce code:
---------------
  function __construct($db_host, $db_username, $db_password, $db_name) {
    $this->link_id = mysql_connect($db_host, $db_username, $db_password);
    if ($this->link_id) {
      if (@mysql_select_db($db_name, $this->link_id)) return $this->link_id;
      else error('Impossible de se connecter ? la base de donn?es. MySQL dit : '.mysql_error(), __FILE__, __LINE__);
    }
    else error('Impossible de se connecter au serveur MySql. MySQL dit : '.mysql_error(), __FILE__, __LINE__);
  }


Expected result:
----------------
Connecting to data base


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-22 18:17 UTC] felipe@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.

See bug #50172
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 07:01:30 2024 UTC