php.net |  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
Votes:1
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
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: kugel at rci dot rutgers dot edu
New email:
PHP Version: OS:

 

 [2010-02-25 18:25 UTC] kugel at rci dot rutgers dot edu
Description:
------------
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 'mysql.vobj.org' (2)"

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

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

NOTE: vobj.org is hosted by dreamhost, and while mysql.vobj.org maps 
to 
67.205.28.132, 67.205.28.132 maps to thadison.masevo.dreamhost.com.
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:
---------------
<?php

# $host='67.205.28.132';
$host='mysql.vobj.org';
$database='bugdemo';
$dbuser='bugdemo';
$pw='PHPisGreat';

$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";
mysql_close($link);
?>

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

Actual result:
--------------
Could not connect: MySQL server host 'mysql.vobj.org' (2)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-09 20:48 UTC] jani@php.net
-Package: Feature/Change Request +Package: MySQL related
 [2010-05-11 12:46 UTC] andrey@php.net
-Status: Open +Status: Feedback
 [2010-05-11 12:46 UTC] andrey@php.net
Operating system?
 [2010-05-11 12:47 UTC] andrey@php.net
-Assigned To: +Assigned To: mysql
 [2010-05-11 12:55 UTC] pajoye@php.net
Fedora 11 host, Apache/2.2.13 (Fedora) (from the report)
 [2011-11-04 10:15 UTC] uw@php.net
-Status: Feedback +Status: Bogus
 [2011-11-04 10:15 UTC] uw@php.net
There are no IP checks in libmysql.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 07:01:31 2024 UTC