DB first time use
| From: | Nunners | Date: | Mon, 26 Apr 2004 09:50:32 +0000 |
| Subject: | DB first time use | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-12119@lists.php.net to get a copy of this message | ||
Hi All,
I'm doing a project, and am trying to use DB for the first time.
I've got as far as the following:
<?php
require_once("DB.php");
$dsn = array(
'phptype' => 'mysql',
'username' => 'root',
'password' => 'password',
'hostspec' => 'localhost',
'database' => 'portal',
);
$options = array(
'debug' => 2,
'portability' => DB_PORTABILITY_ALL,
);
$db =& DB::connect($dsn, $options);
if (DB::isError($db)) {
die($db->getMessage());
}
$sql = 'select * from agents';
$res =& $db->query($sql);
if (DB::isError($res)) {
die($res->getMessage());
}
echo $res->numRows(); // returns 1
while ($res->fetchInto($agent)) {
echo $agent['name'] . "\n"; //returns Undefined index: Name
}
?>
As you can see from my comments, it correctly returns the number of rows,
however doesn't recognize any indexes. I've installed the latest version
1.6.2....
Am I doing something really silly?
Cheers
James