RE: [PEAR] PEAR DB Error

From: Date: Mon, 23 Apr 2001 20:45:58 +0000
Subject: RE: [PEAR] PEAR DB Error
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-74@lists.php.net to get a copy of this message
Well, the exact code I'm using is: <? require_once 'DB.php'; $user = 'myuser'; $pass = 'mypass'; $host = 'localhost'; $dbname = 'workout'; $dsn = "mysql://$user:$pass@$host/$dbname"; echo "About to connect!<br>$dsn<br>"; $db = DB::connect(dsn, array("debug" => 2)); if (DB::isError($db)) { die($db->getMessage()); } else { echo "connected!<br>"; } $sql = 'select * from equipment'; $result = $db->query($sql); if (DB::isError($result)) { die($db->getMessage()); } else { echo "Query executed!<br>"; } while ($row = $result->fetchRow()) { printf("it is ". $row[1] . "<br>"); } ?> and I'm receiving: About to connect! mysql://myuser:mypass@localhost/workout Warning: Failed opening 'DB/dsn.php' for inclusion (include_path='/usr/local/lib/php/pear') in DB.php on line 230 DB Error: not found It's getting frustrating. I have no idea why it's looking for dsn.php instead of mysql.php. Also, when I change line 230 from: include_once "DB/${type}.php" to: include_once "DB/mysq.php" I get: About to connect! mysql://myuser:mypass@localhost/workout DB Error: not found Thanks for any help! Chris -----Original Message----- From: cox@idecnet.com [mailto:cox@idecnet.com] Sent: Monday, April 23, 2001 3:19 PM To: Chris Mulcahy Subject: Re: [PEAR] PEAR DB Error Chris Mulcahy wrote: > > Hmm. Replying to my own message. > > On reading through the archives, I found this tidbit. > $dbh = DB::connect($dsn, array("debug" => 2)); > in a message from Stig Sæther Bakken > > On adding the debug level 2, I get: > Warning: Failed opening 'DB/dsn.php' for inclusion > (include_path='/usr/local/lib/php/pear') in DB.php on line 230 This error can only occur when you supply to connect, something like: $dsn = 'dsn://blah'; $db = DB::connect($dsn); Perhaps you are doing: $dsn = 'mysql://blah'; $db = DB::connect(dsn); // <-- without '$' Please check that. If not, please be more verbose and paste the exactly code that is given problems (always use the last CVS version and php >= 4.0.4). Tomas V.V.Cox

« previous php.pear.general (#74) next »