note 92696 rejected from ref.pdo-mysql.connection by danbrown

From: Date: Tue, 04 Aug 2009 17:06:12 +0000
Subject: note 92696 rejected from ref.pdo-mysql.connection by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-159092@lists.php.net to get a copy of this message
Note Submitter: drunks at gmail dot com ---- maybe this is just a bug in php5.3 ... but pdo-mysql seems to have issues between hostname and ip address. for example this fails with pdo exception when using a hostname. <?php $dsn = 'mysql:host=localhost;dbname=test'; $user = 'root'; $password = 'pass'; $dbh = new PDO($dsn, $user, $password); ?> Warning: PDO::__construct() [pdo.--construct]: [2002] Invalid argument (trying to connect via unix://) PDOException: SQLSTATE[HY000] [2002] Invalid argument but this works just fine just changing to ip address. <?php $dsn = 'mysql:host=127.0.0.1;dbname=test'; $user = 'root'; $password = 'pass'; $dbh = new PDO($dsn, $user, $password); ?> this makes no sense since i can connect to mysql from command line with either host or ip.

« previous php.notes (#159092) next »