help with PEAR::DB vs mysql_connect

From: Date: Sat, 20 Sep 2003 02:14:41 +0000
Subject: help with PEAR::DB vs mysql_connect
Groups: php.db 
Request: Send a blank email to php-db+get-30587@lists.php.net to get a copy of this message
I have 2 seperate scripts. On useing PEAR::DB and the other using mysql_connect. mysql_connect works and PEAR::DB does not. This is what I have... the 'mysql_connect' script... $db_host = 'myHost'; $db_user = 'myUser'; $db_pass = 'myPass'; $db_name = 'myDB'; $link = mysql_connect($db_host, $db_user, $db_pass) or die("Could not connect: " . mysql_error()); mysql_select_db($db_name, $link); $result = mysql_query("SELECT * FROM myTable", $link); $num_rows = mysql_num_rows($result); echo "$num_rows Rows\n"; this gives me '38', which it is supposed to. the PEAR::DB sscript... $db_type = 'mysql'; $db_host = 'myHost'; $db_user = 'myUser'; $db_pass = 'myPass'; $db_name = 'myDB'; $dsn = "$db_type://$db_user:$db_pass@$db_host/$db_name"; $db = DB::connect($dsn); if (DB::isError($db)) die ($db->getMessage()); else echo "DB Connected to $db_name \n\n"; $result = $db->query(("SELECT * FROM myTable"); echo 'rec count: ' . $result->numRows(); This gives me... DB Error: connect failed I have no idea what I am doing wrong! Both scripts work on my local machine, but only the 'mysql_connect' works on the production server. I even took the step of placing the vars in an include file that open open, just to make sure both were using the same values. Any ideas what I'm doing wrong? Thanks Walter

« previous php.db (#30587) next »