php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56315 Unable to create PDO Object
Submitted: 2005-02-21 06:33 UTC Modified: 2005-02-21 11:11 UTC
From: ansriniv at in dot ibm dot com Assigned: hholzgra (profile)
Status: Closed Package: PDO_MYSQL (PECL)
PHP Version: 5.0.3 OS: Linux IA32 RHEL3
Private report: No CVE-ID: None
 [2005-02-21 06:33 UTC] ansriniv at in dot ibm dot com
Description:
------------
Hello,

When I am trying to create PDO object with the following 
dsn, i am getting the following error.
$dsn='mysql:dbname=test;host=localhost';

Connection failed
SQLSTATE[HY000] [2005] Unknown MySQL server host '.' (4)

However, if i change the dsn string to something like 
$dsn='mysql:dbname=test;host=127.0.0.1';
there seem to be no problem.

AS you can see, in the second case, i am passing the host IP address instead of string 'localhost';

my /etc/hosts file looks like below.

<root@localhost /opt/IBMIHS/htdocs/en_US> cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost
127.0.0.1               localhost

I am using IHS with PHP 5.0.3 on IA32 box running with RHEL3,

I am not sure whether this is a bug, or is there any thing silly which I am missing.

Thank you,
Srini.

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

//$dsn='mysql:dbname=test;host=127.0.0.1';
$dsn='mysql:dbname=test;host=localhost';
$user='root';
$password='qpoiqpoi';

try {
    $dbh = new PDO($dsn, $user, $password);
    print "PDO Object has been created </br>";
} catch (PDOException $e) {
    print "Connection failed </br>" . $e->getMessage();
}
?>


Expected result:
----------------
PDO Object has been created

Actual result:
--------------
Connection failed
SQLSTATE[HY000] [2005] Unknown MySQL server host '.' (4)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-21 11:11 UTC] hholzgra@php.net
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 01:01:28 2024 UTC