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.