PEAR DB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Can anyone tell me why the code below doesn't work? I have looked at examples
and read documentation until my eyes are crossed, but I swear that mine is
the same as theirs. I don't get any errors. There just isn't any data in
$row. Or at least I get empty output when I echo row. var_dump() says $row is
NULL. 

If I modify this same script, just changing the DB lines to lines with mysql
functions, I get the data I expect from the database. But with the DB
statements, I get nothing. . So, does anyone see what I have wrong?


 $user = "root";
 $passwd = "";
 $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>";
?>

Thanks for any suggestions,

Janet

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux