ID: 34072 User updated by: pash_ka at fonbet dot info Reported By: pash_ka at fonbet dot info -Status: Feedback +Status: Open Bug Type: PDO related Operating System: Windows XP PHP Version: 5.1.0b3 Assigned To: wez New Comment:
I've tried it with latest (Aug 30 2005 08:37:40) build, and using 127.0.0.1 instead of localhost works. I'm using this test script: ------------------------------------------- <?php if(!isset($argv)){ header('Content-type: text/plain'); header("Content-Disposition: inline; filename=dbotest.txt"); } $cfg['host'] = 'localhost'; //$cfg['host'] = '127.0.0.1'; $cfg['port'] = 6733; $cfg['database'] = 'www-new'; $cfg['username'] = 'pasha'; $cfg['password'] = '****'; connect_mysql($cfg); echo "\n"; connect_pdo_mysql($cfg); function connect_mysql($cfg){ $dsn = $cfg['host'].':'.$cfg['port']; echo "Connecting to MYSQL (DSN = {$dsn}).\n"; @$res = mysql_connect($dsn, $cfg['username'], $cfg['password']); echo 'Result: '.($res?'OK':mysql_error())."\n"; return $res; } function connect_pdo_mysql($cfg){ $dsn = "mysql:host={$cfg['host']};port={$cfg['port']};dbname={$cfg['database']}"; echo "Connecting to PDO_MYSQL (DSN = {$dsn}).\n"; try{ $res = new PDO($dsn, $cfg['username'], $cfg['password']); echo "Result: OK\n"; return $res; }catch(PDOException $ex){ echo 'Result: '.$ex->getMessage()."\n"; return false; } } ?> ------------------------------------------- And this is the result when using localhost: ------------------------------------------ Connecting to MYSQL (DSN = localhost:6733). Result: OK Connecting to PDO_MYSQL (DSN = mysql:host=localhost;port=6733;dbname=www-new). Result: SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'localhost' (10061) ------------------------------------------ Previous Comments: ------------------------------------------------------------------------ [2005-08-30 01:05:46] [EMAIL PROTECTED] Does it work if you change the hostname to 127.0.0.1? ------------------------------------------------------------------------ [2005-08-10 18:44:28] [EMAIL PROTECTED] Wez, could you plz check it out? ------------------------------------------------------------------------ [2005-08-10 18:44:18] [EMAIL PROTECTED] I've just copied your DSN and it worked for me. But IIRC it's possible that it automagically uses local socket on my Linux, which is not available on Win32. ------------------------------------------------------------------------ [2005-08-10 18:38:40] pash_ka at fonbet dot info Well, I've just downloaded php5-win32-latest.zip - it's the same one (Aug 9 2005 ) and tried with it. The bug is still there for me. Do i need to use "mysql:host=localhost;port=6733;dbname=www" dsn or there is another syntax to specify port? ------------------------------------------------------------------------ [2005-08-10 18:22:42] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip Can't reproduce. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/34072 -- Edit this bug report at http://bugs.php.net/?id=34072&edit=1