Jump to content
Larry Ullman's Book Forums

Error In Home Html


Recommended Posts

Hello, I'm at the end of chapter 8 of your Effortless book and keep getting the following error message when I open up my site.

 

The line 15 in home.html referenced below is the following : >> if (mysqli_num_rows($r) > 0) {Could you please help?. I've double checked all the files and the stored procedure in index.php does return some rows, so not sure why this is not working

 

 

An error occurred in script '\xxx\html\views\home.html' on line 15:

mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given

 

Array

(

[0] => Array

(

[function] => my_error_handler

[args] => Array

(

[0] => 2

[1] => mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given

[2] => xxx\html\views\home.html

[3] => 15

[4] => Array

..and so on.

Link to comment
Share on other sites

Thanks, Stuart

 

Here's when I echo out the mysqli_error: "Unknown column 'sv.venue_id' in 'on clause'"

 

Not sure which query I should post here, but here's a couple

 

1) Query in the home.html

if (mysqli_num_rows($r) > 0) {

 

echo '<dl class="special fright">

<dt><a href="/shop/sales/">Sale Items</a></dt>';

 

// Fetch each item:

while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {

echo '<dd><a href="/shop/sales/#' . $row['sku'] . '" title="View This Product"><img alt="" src="/products/' . $row['image'] . '" /><span>' . $row['sale_price'] . '</span></a></dd>';

}

 

echo '</dl>';

 

2) the stored procedure query index.php is trying to reference to return some rowsCREATE PROCEDURE select_sale_items (get_all BOOLEAN)

BEGIN

IF get_all = 1 THEN

SELECT CONCAT("O", nvp.id) AS sku, sa.price AS sale_price, nvc.category, nvp.image, nvp.name, nvp.price, nvp.stock, nvp.description FROM sales AS sa INNER JOIN non_venue_products AS nvp ON sa.product_id=nvp.id INNER JOIN non_venue_categories AS nvc ON nvc.id=nvp.non_venue_category_id WHERE sa.product_type="other" AND ((NOW() BETWEEN sa.start_date AND sa.end_date) OR (NOW() > sa.start_date AND sa.end_date IS NULL) )

UNION SELECT CONCAT("v", sv.id), sa.price, gv.category, gv.image, CONCAT_WS(" - ", s.size, sv.meal, sv.drinks), sv.price, sv.stock, gv.description FROM sales AS sa INNER JOIN specific_venues AS sv ON sa.product_id=sv.id INNER JOIN sizes AS s ON s.id=sv.size_id INNER JOIN general_venues AS gv ON gv.id=sv.general_venue_id WHERE sa.product_type="venue" AND ((NOW() BETWEEN sa.start_date AND sa.end_date) OR (NOW() > sa.start_date AND sa.end_date IS NULL) );

ELSE

(SELECT CONCAT("O", nvp.id) AS sku, sa.price AS sale_price, nvc.category, nvp.image, nvp.name FROM sales AS sa INNER JOIN non_venue_products AS nvp ON sa.product_id=nvp.id INNER JOIN non_venue_categories AS nvc ON nvc.id=nvp.non_venue_category_id WHERE sa.product_type="other" AND ((NOW() BETWEEN sa.start_date AND sa.end_date) OR (NOW() > sa.start_date AND sa.end_date IS NULL) ) ORDER BY RAND() LIMIT 2) UNION (SELECT CONCAT("v", sv.id), sa.price, gv.category, gv.image, CONCAT_WS(" - ", s.size, sv.meal, sv.drinks) FROM sales AS sa INNER JOIN specific_venues AS sv ON sa.product_id=sv.id INNER JOIN sizes AS s ON s.id=sv.size_id INNER JOIN general_venues AS gv ON gv.id=sv.venue_id WHERE sa.product_type="venue" AND ((NOW() BETWEEN sa.start_date AND sa.end_date) OR (NOW() > sa.start_date AND sa.end_date IS NULL) ) ORDER BY RAND() LIMIT 2);

END IF;

END$$

DELIMITER ;

Link to comment
Share on other sites

 Share

×
×
  • Create New...