php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52516 host name of localhost doesn't work any more
Submitted: 2010-08-02 15:32 UTC Modified: 2010-08-02 15:48 UTC
From: dev at focus-computing dot com dot au Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.3.3 OS: Windows 7
Private report: No CVE-ID: None
 [2010-08-02 15:32 UTC] dev at focus-computing dot com dot au
Description:
------------
When asked to specify a server in a TCP/IP environment the name 'localhost' has always worked - it works with lots of other packages.  However it is clearly not working with the latest mysqlnd driver.  We have to specify 127.0.0.1 - which to me has always been synonymous with 'localhost'.

Can we please have the option of specifying 'localhost' back?

I understand there are technical reasons for using the IP address, but this is really hard to explain to our bosses: why the upgrade failed, why the system was down for 3 days, and specifically why this setting was changed to begin with - they just don't understand - I barely understand.

Two lines of code should do it:
if ($servername == 'localhost')
  $servername = '127.0.0.1';

PS: I know I've written php but the C code is equally short.



Test script:
---------------
mysql_connect('localhost', 'root', 'secret');
mysql_connect('127.0.0.1', 'root', 'secret');


Expected result:
----------------
To be able to specify the mysql server name as 'localhost'


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-02 15:48 UTC] johannes@php.net
-Status: Open +Status: Bogus
 [2010-08-02 15:48 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Please see this blog post: http://blogs.iis.net/donraman/archive/2010/06/11/php-5-3-and-mysql-connectivity-problem.aspx
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 11:01:30 2024 UTC