DB problem

From: Date: Tue, 17 Jun 2003 01:49:01 +0000
Subject: DB problem
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-6017@lists.php.net to get a copy of this message
Can someone tell my why the following program doesn't work. It doesn't give me any error messages, but it doesn't get the data either. In the echo statement at the end, $row['PType'] is empty. The var_dump shows it to be NULL. However, when I run this exact same program, with the same $user, $passwd, etc., using the mysql functions, it gives me the proper results. What am I missing? <?php require_once("DB.php"); # includes PEAR DB classes $host = "localhost"; $user = "account"; $passwd = "password"; $dbname = "Test"; $dbtype = "mysql"; $dsn = "$dbtype://$user:$passwd@$host/$dbname"; echo "dsn=$dsn<br>"; $db = DB::connect($dsn) or die("connect died"); if(DB::isError($db)) { die ("connect died"); } $sql = "SELECT * from producttype"; $result = $db->query($sql) or die("query died"); if(DB::iserror($result)) { die ("query died"); } $row = $db->fetchRow(DB_FETCHMODE_ASSOC); if(DB::iserror($row)) { die("bad row"); } echo "row={$row['PType']}<br>"; echo "<pre>"; var_dump($row); echo "</pre>"; ?> Also, according to the manual, I should be able to use fetchRow(), without a parameter. However, when I do that, it complains about a missing argument. Thanks for any help, Janet

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