Re: Converting to Pear

From: Date: Sat, 14 Sep 2002 18:49:49 +0000
Subject: Re: Converting to Pear
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-116393@lists.php.net to get a copy of this message
On 14 Sep 2002 at 13:20, Gary wrote: > I am in the process of learning Pear. I though that converting an old > script would be the way to go. Everything has been going well until now > when i get the error, Notice: Undefined index: for tutorial, owner, and > address in the following code. Where am I screwing up? > > while ($row = $res->fetchRow()){ > $tutorial = $row["tutorial"]; > $owner = $row["owner"]; > $address = $row["address"]; Gary, fetch (see below, link to docs) returns an array, not an associative array. You could do a print_r($row) to verify. You might want to look at this DB_FETCHMODE_ASSOC Docs here: http://pear.php.net/manual/en/core.db.tut_fetch.php > The fetch*() returns an ordered array. The order is taken from the > select statment. <?php $res = $db->query('select id, name, email from > users'); $row = $res->fetchRow(DB_FETCHMODE_ORDERED); /* $row will > contain: array ( > 0 => <column "id" data>, > 1 => <column "name" data>, > 2 => <column "email" data> > ) > */ > // Access the data with: > $id = $row[0]; > $name = $row[1]; > $email = $row[2]; > ?> Peter http://www.coremodules.com/ Web Development and Support at Affordable Prices

« previous php.general (#116393) next »