Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Trying to list all products without contribution


joemurray

Recommended Posts

Posted

Hi all. I'm trying to list all of the products on a page without having to install any contributions or make changes to the database. I'm using very simple php and I keep getting mysql errors. Here is the code:

 

<?php

		$cnct = mysql_connect("localhost", "username", "password");
		mysql_select_db("poisenivy", $cnct);

		if (!$cnct)
			{
			echo "There is a problem with the database connection.";
			}

		$allprods = "SELECT * FROM Products WHERE products_quantity>'0'";
		$allresult = mysql_query($allprods);
		$allrows = mysql_num_rows($allresult);

		if ($allrows = 0) 
			{
			echo "There were no products returned";
			} 




		while($arow = mysql_fetch_assoc($allresult))
			  {
			  echo "<table width='100%' cellspacing='5'><tr><td><img src='http://www.poisenivygifts.com/images/" . $arow["products_image"] . "'></td><td> " . $arow["products_price"] . "</td></tr></table>";
			  echo "<br />";
			  }

		?>

 

Here are the errors that I keep getting:

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/u3/poisenivy/html/all_products.php on line 66

 

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/u3/poisenivy/html/all_products.php on line 76

 

I'm pretty new to php so it may be something simple that I'm just overlooking. Could anyone shed some light on this?

 

By the way, I removed the correct username/password purposely so that isn't the problem.

Posted

I have found a quick fix solution to this but if anyone has any advice or could debug the above code for me then it would be greatly appreciated!

Posted

You could try to remove the quotes on 0 make the Products lowercase:

$allprods = "SELECT * FROM products WHERE products_quantity > 0";

Other great Open Source (Free) programs: (Free as in free speech not free beer)

The Gimp - An image program. | Firefox - All you have to do is add the Web Developer add-on to make this web browser complete. | FileZilla - An ftp program. | Inkscape - A good program to create images with. | Thunderbird - An email program. | Openoffice.org - An office suite that is compatible with MS Office. | Abiword - Another office suite. | Audacity - A sound recording tool. | ddp's Picks | Wordpress - An easy to use blogging software. | Joomla - An easy to use CMS that has ecommerce plug-ins. | Drupal - Another CMS

How do I find these programs? Google Search!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...