|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51147 mysql_connect can't resolve hostname within apache module
Submitted: 2010-02-25 18:25 UTC Modified: 2011-11-04 10:15 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: kugel at rci dot rutgers dot edu Assigned: mysql (profile)
Status: Not a bug Package: MySQL related
PHP Version: 5.2.12 OS:
Private report: No CVE-ID: None
 [2010-02-25 18:25 UTC] kugel at rci dot rutgers dot edu
When this is run from the command line: "php mytest.php" on the local 
machine, it connects successfully to the remote database.  When it's 
run as a webpage, it dies with the mysql_error message of "Unknown 
MySQL server host '' (2)"

Command line access "mysql -h ..." works fine.

If I substitute the IP address for the hostname, the webpage connects.

NOTE: is hosted by dreamhost, and while maps 
to, maps to
Maybe there's some IP security check that causes failure without 
generating a useful error message.

Fedora 11 host, Apache/2.2.13 (Fedora)

Reproduce code:

# $host='';

$link = mysql_connect($host,$dbuser,$pw)
    or die('Could not connect: ' . mysql_error() );
mysql_select_db($database) or die('Could not select database '.$database);

echo "successful connection<br />\n";

Expected result:
Code should say "successful connection<br />\n"

Actual result:
Could not connect: MySQL server host '' (2)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-09 20:48 UTC]
-Package: Feature/Change Request +Package: MySQL related
 [2010-05-11 12:46 UTC]
-Status: Open +Status: Feedback
 [2010-05-11 12:46 UTC]
Operating system?
 [2010-05-11 12:47 UTC]
-Assigned To: +Assigned To: mysql
 [2010-05-11 12:55 UTC]
Fedora 11 host, Apache/2.2.13 (Fedora) (from the report)
 [2011-11-04 10:15 UTC]
-Status: Feedback +Status: Bogus
 [2011-11-04 10:15 UTC]
There are no IP checks in libmysql.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 19 12:03:36 2021 UTC