Re: Database Problem
| From: | Matt McClanahan | Date: | Tue, 11 Jul 2000 18:08:51 +0000 |
| Subject: | Re: Database Problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-5965@lists.php.net to get a copy of this message | ||
On Tue, 11 Jul 2000, Jeff Wilhelm wrote:
> This code is suppsed to go into the database in grab the records with the
> provided 'productid' and print each one of them out. For some reason it is
> only returning 'Resource id #2' (or multiple 'Resource id #2' if there is
> more than one record with that productis). Anyone have any ideas? I'm sure
> it's a simple mistake...
> -Jeff
>
> <?
> include "database.inc";
>
> $productid = "61";
> $comments = mysql_query("select comment from comments where productid =
> $productid") or die(mysql_error());
>
> if ($comments) {
> while (mysql_fetch_array($comments)) {
> print "$comments";
> }
> }
> ?>
$comments here is your result identifier (Hence, it's giving you "Resource
id #2". What you want to do is say
while( $row = mysql_fetch_array($comments) ) {
print $row[<field name>];
}
Matt