Re: DB first time use

From: Date: Mon, 26 Apr 2004 19:45:02 +0000
Subject: Re: DB first time use
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-12141@lists.php.net to get a copy of this message
I think 'name' is a reserved word in mySQL. > 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 > > -- > PEAR General Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

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