...

View Full Version : pg_fetch_object and while prints "Resource id#3"... ??



nockemout
05-23-2011, 09:58 PM
hmProdQuery= pg_query($dbcon, "SELECT id, name, author, price, publisher, image, description FROM eza_products");
while ($product = pg_fetch_object($hmProdQuery)) //loop through each row, store each column/value that is selected into an object called
{
echo "<img id='bookimg' width='92' height='119' src='images/bookimages/$product->image'>\n"; //show the image field for the current row.
echo "<img id='tag' src=images/tag.gif>\n";
echo "<p id=dispPrice class=dispPrice>$product->price</p>\n"; //object notation, similar to $row[0] or $row['name']
echo "<p id=bookTitle class=bookTitle>$product->name</p>\n";
echo "<p id=author class=author>$product->author $product->publisher</p>\n";
echo "<p id=description class=description>$product->description</p>\n";
if ($_SESSION['logged'] == true) { //if the user is logged in...offer them to add this product into their session
echo "<button type='button'><a href='cart.php?action=add&id=$product->id'>Add to Cart</button>\n";
} else { //otherwise, provide a link to login.
echo "<button type='button'><a href='login.php'>Login</a></button>\n\n";
}
}



Results in:



Resource id #3<img id='bookimg' width='92' height='119' src='images/bookimages/image01.jpg'>
<img id='tag' src=images/tag.gif>
<p id=dispPrice class=dispPrice>19.99</p>
<p id=bookTitle class=bookTitle>PHP and MySQL</p>
<p id=author class=author>Luke Welling Pearson Education</p>
<p id=description class=description>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam accumsan bibendum odio, ut pretium leo cursus quis. Nullam eget magna lobortis libero consequat lacinia ut in tellus. </p>
<button type='button'><a href='login.php'>Login</a></button>



Why does Resource id#3 show up and how do i get rid of it...?

EDIT:

oops... I had




echo $dbcon;



silly me. Fixed. Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum