Duke Posted August 30, 2014 Share Posted August 30, 2014 RE: checkout.php...p 301 step17...just showing a work around that works at this stage of chp 10 could not get this line to return the id...$r = mysqli_query($dbc, 'SELECT @cid'); as a result there is no value to store in list($_SESSION['customer_id']) = mysqli_fetch_array($r);...(even reworked the stored procedure for add_customer..no luck My work around: I set $cid = mt_rand(100000,1000000000); added customer_id column to customer's table.... changed the stored procedure=add_customer...to also include customer_id...and....VALUE.... $cid changed setting session to: $_SESSION['customer_id'] = $cid; this seems to be working at this stage of chp 10... Link to comment Share on other sites More sharing options...
Larry Posted September 2, 2014 Share Posted September 2, 2014 Thanks for sharing that! Link to comment Share on other sites More sharing options...
Duke Posted September 6, 2014 Author Share Posted September 6, 2014 using the above work around....in chapter 11.... for view_orders.php script I changed the query to $q = 'SELECT o.id, FORMAT(total/100, 2) AS total, c.customer_id AS cid, CONCAT(last_name, ",", first_name) AS name, city, state,zip, COUNT(oc.id) AS items FROM orders AS o LEFT OUTER JOIN order_contents AS oc ON (oc.order_id=o.id AND oc.ship_date IS NULL) JOIN customers AS c ON (o.customer_id = c.customer_id) JOIN transactions AS t ON (t.order_id=o.id AND t.response_code=1) GROUP BY o.id DESC'; for the view_order.php script I changed the query to $q ='SELECT FORMAT(total/100, 2) AS total, FORMAT(shipping/100,2) AS shipping, credit_card_number, DATE_FORMAT(order_date, "%a %b %e, %Y at %h:%i%p") AS od, email, CONCAT(last_name, ", ", first_name) AS name, CONCAT_WS(" ", address1, address2, city, state, zip) AS address, phone, o.customer_id, CONCAT_WS(" - ", ncc.category, ncp.name) AS item, ncp.stock, quantity, FORMAT(price_per/100,2) AS price_per, DATE_FORMAT(ship_date, "%b %e, %Y") AS sd FROM orders AS o INNER JOIN customers AS c ON (o.customer_id = c.customer_id) INNER JOIN order_contents AS oc ON (oc.order_id = o.id) INNER JOIN non_coffee_products AS ncp ON (oc.product_id = ncp.id AND oc.product_type="goodies") INNER JOIN non_coffee_categories AS ncc ON (ncc.id = ncp.non_coffee_category_id) WHERE o.id=' .$order_id. 'UNIONSELECT FORMAT(total/100, 2), FORMAT(shipping/100,2), credit_card_number, DATE_FORMAT(order_date, "%a %b %e, %Y at %l:%i%p"), email, CONCAT(last_name, ", ", first_name), CONCAT_WS(" ", address1, address2, city, state, zip), phone, o.customer_id, CONCAT_WS(" - ", gc.category, s.size, sc.caf_decaf, sc.ground_whole) AS item, sc.stock, quantity, FORMAT(price_per/100,2), DATE_FORMAT(ship_date, "%b %e, %Y") FROM orders AS o INNER JOIN customers AS c ON (o.customer_id = c.customer_id) INNER JOIN order_contents AS oc ON (oc.order_id = o.id) INNER JOIN specific_coffees AS sc ON (oc.product_id = sc.id AND oc.product_type="coffee") INNER JOIN sizes AS s ON (s.id=sc.size_id) INNER JOIN general_coffees AS gc ON (gc.id=sc.general_coffee_id) WHERE o.id='.$order_id; ..seems to work . I am going to check it more...just wanted to add above in case anyone uses mt_rand() for customer id Thank you Link to comment Share on other sites More sharing options...
Duke Posted September 14, 2014 Author Share Posted September 14, 2014 In keeping with what I am using in this topic.. in chapter 13 page 423.... I changed the query as follows(need to change in 2 places originally............INNER JOIN customers AS c ON (o.customer_id = c.id) I changed to .....INNER JOIN customers AS c ON (o.customer_id = c.customer_id) Thank you Link to comment Share on other sites More sharing options...
Larry Posted September 15, 2014 Share Posted September 15, 2014 Thanks again for continuing to share! Link to comment Share on other sites More sharing options...
Recommended Posts