Beginner trouble

Hi all, this is my first post on here and I am sure this will become a common hang out for me through my self-education process of PHP. Any and all suggestions are appreciated. As well as some possible pointers to other shopping cart tutorials. I want my end result to be able to send me an email with the order to be bill offline.

Thanks in advance!

I am programming a shopping cart based on a tutorial. I have checked and double checked the entire code and cannot find the error.

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/zproducts.php on line 11

[php]if(isset($_GET[‘action’]) && $_GET[‘action’] == “add”) {
$id = intval($_GET[‘id’]);
if(isset($_SESSION[‘cart’][$id])) {
$_SESSION[‘zcart’][$id][‘quantity’]++;
} else {
$sql2 = “SELECT * FROM products WHERE id_product=[$id]”;
$query2 = mysql_query($sql2);

	                if(mysql_num_rows($query2) != 0) {        ####line 11
			$row2 = mysql_fetch_array($query2);
			$_SESSION['cart'][$row2['id_product']] = array("quantity" => 1, "price" => $row2['price']);
		
		} else {
			$message = "This product id is invalid";
		} 
	}
}[/php]

I have a feeling the issue isnt actually in line 11. its just the end of a string of variables that actually tries to do something with the query. Let me know if more info is needed.

[php]$sql2 = “SELECT * FROM products WHERE id_product=$id”;[/php]

Thank you for the reply… It actually did not solve the problem… BUT, it got me looking at it again. on a different page I typoed SELECT, as SELLECT! so it wasnt getting the query info it needed. N00b mistake here!

Thanks again for the help.

Andrew

I am sorry if am little late to reply. You choose very right place for your problem I was also looking for a new bie here. Hope you have got your problem fixed as I know that I would also be in need of you guys very soon.

Sponsor our Newsletter | Privacy Policy | Terms of Service