JBruner Posted June 12, 2012 Share Posted June 12, 2012 I had to rewrite the stored procedures since my hosting doesn't allow EXECUTE capabilities. I do all of my coding in Dreamweaver because I find the color coding is easier to find errors. I am not an expert in PHP by any means, but I can usually get my way around. So in copying the scripts Larry provided in his Rewriting Stored Procedures blog I get a couple errors (highlighted in red): if ($type == 'coffee') { $r = mysqli_query($dbc, 'SELECT gc.description, gc.image, CONCAT("C", sc.id) AS sku, CONCAT_WS(" - ", s.size, sc.caf_decaf, sc.ground_whole, sc.price) AS name, sc.stock, sc.price, sales.price AS sale_price FROM specific_coffees AS sc INNER JOIN sizes AS s ON s.id=sc.size_id INNER JOIN general_coffees AS gc ON gc.id=sc.general_coffee_id LEFT OUTER JOIN sales ON (sales.product_id=sc.id AND sales.product_type='coffee' AND ((NOW() BETWEEN sales.start_date AND sales.end_date) OR (NOW() > sales.start_date AND sales.end_date IS NULL)) ) WHERE general_coffee_id=' . $sp_cat . ' AND stock>0 ORDER by name'); } elseif ($type == 'goodies') { $r = mysqli_query($dbc, 'SELECT ncc.description AS g_description, ncc.image AS g_image, CONCAT("O", ncp.id) AS sku, ncp.name, ncp.description, ncp.image, ncp.price, ncp.stock, sales.price AS sale_price FROM non_coffee_products AS ncp INNER JOIN non_coffee_categories AS ncc ON ncc.id=ncp.non_coffee_category_id LEFT OUTER JOIN sales ON (sales.product_id=ncp.id AND sales.product_type='other' AND ((NOW() BETWEEN sales.start_date AND sales.end_date) OR (NOW() > sales.start_date AND sales.end_date IS NULL)) ) WHERE non_coffee_category_id=' . $sp_cat . ' ORDER by date_created DESC'); } Am I correct in saying that coffee and goodies should be double quotation marks: "coffee" "goodies"? Link to comment Share on other sites More sharing options...
Larry Posted June 13, 2012 Share Posted June 13, 2012 Yes, that is correct. Your entire query is within single quotes, so those strings need to be within double quotes. Link to comment Share on other sites More sharing options...
Recommended Posts