What version of PHP? What version of MySQL?
while your at it what version of PEAR::DB ;-)
-----Original Message----- From: Jason Davis [mailto:cephme@xxxxxxxxx] Sent: Thursday, January 06, 2005 10:42 AM To: php-db@xxxxxxxxxxxxx Subject: Trying to connext to MySQL with PEAR
Hi all I am new to PHP and am trying to connect to mysql for the first time. I get activity on the mysql monitor when I run it, but get the following error.
if this is your first time & your new to PHP I would suggest that you try the mysql_*() function directly before moving to an Abstraction class. that way you are closer to the 'problem' and you also learn the underlying functions that the (PEAR) class(es) use.
DB Error: connect failed
The lines of code are: require_once( "DB.php" ); $dsn = "mysql://".DB_USER.":".DB_PASS."@".DB_SERVER."/".DB_NAME; echo $dsn; $isPersistant = TRUE;
doesn't effect the code but 'Persistant' is spelled 'Persistent'
$db = DB::connect($dsn, $isPersistant);
if ( DB::isError( $db ) ) {
try placing the following here (here as in: in this spot in your code). not sure if this will work - depends on exactly what goes on inside the PEAR DB class - but I guess it will show you a more helpful error than the class does:
print_r( mysql_error() );
die ($db->getMessage()); }
The constants are properly defined and passing through to this page (checked with echo), the database is created, the user has an account, and the account has rights to do all funcitons on the db. Any thoughts on what might be wrong?
Thanks Jason
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php