Jump to content
Larry Ullman's Book Forums

100yen

Members
  • Content Count

    42
  • Joined

  • Last visited

  • Days Won

    1

100yen last won the day on September 11 2013

100yen had the most liked content!

Community Reputation

2 Neutral

About 100yen

  • Rank
    Member
  1. Hi, I run into trouble sending html email to hotmail and aol address using php mail() function. Gmail and Yahoo are fine. But hotmail and aol are failed to receive anything. Here is my header setting $headers = "From: sales@thtc-usa.com\r\n"; $headers .= "Reply-To: sales@thtc-usa.com\r\n"; $headers .= "Return-Path:sales@thtc-usa.com\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; any suggestion please?
  2. Hi, I am reading this book at second time. At advance Event Handling section, I am confusing about the statement that describes 'return false' vs 'e.preventDefault()'. At page 290, Larry writes 'On any browser that supports the addEventListener() method, event handlers will automatically receive a single argument, which represents the event that occurred. I think the single argument is event object, right? At page 298, 'For browsers that don't support the addEventListener() method, an alternative way of preventing the default event behavior is to invoke the preventDefaut() method of the event object. My question is that since the browser don't support addEventListener() method, there should be no event object received as argument. Then how come the alternative way of using event.preventDefault( )?
  3. Hi, Larry. I am reading into chapter 2 or your Yii book. It's time to download the Yii application. The Yill download page offers Yii 1.14 or 2.0. The 2.0 is a complete rewrite and it's not compatible with 1.1. So which one should I download? thanks.
  4. and here is the statement block that comes from the add_order procedure. It works to me, so post it as reference if (empty($billing_errors)) { $cc_exp = sprintf('%02d%d', $_POST['cc_exp_month'], $_POST['cc_exp_year']); // check for existing order ID in the session // to prevent double orders if (isset($_SESSION['order_id'])) { $order_id = $_SESSION['order_id']; $order_total = $_SESSION['order_total']; } else { // if no existing order ID, get the last four digitals of cc number $cc_last_four = substr($cc_number, -4); // store the order: $shipping = $_SESSION['shipping']; // Insert into orders table $query = "INSERT INTO orders (customer_id, shipping, credit_card_number,order_date) VALUES ({$_SESSION['customer_id']}, $shipping, $cc_last_four, NOW())"; $result = mysqli_query($dbc, $query); if (mysqli_affected_rows($dbc) == 1) { $oid = mysqli_insert_id($dbc); // Insert into order_contents $query = " INSERT INTO order_contents (order_id, product_type, product_id, quantity, price_per) SELECT $oid, c.product_type, c.product_id, c.quantity, IFNULL(sales.price, ncp.price) FROM carts AS c INNER JOIN non_coffee_products AS ncp ON c.product_id=ncp.id LEFT OUTER JOIN sales ON (sales.product_id=ncp.id AND sales.product_type='goodies' AND ((NOW() BETWEEN sales.start_date AND sales.end_date) OR (NOW() > sales.start_date AND sales.end_date IS NULL))) WHERE c.product_type=\"goodies\" AND c.user_session_id='$uid' UNION SELECT $oid, c.product_type, c.product_id, c.quantity, IFNULL(sales.price, sc.price) FROM carts AS c INNER JOIN specific_coffees AS sc ON c.product_id=sc.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 c.product_type=\"coffee\" AND c.user_session_id='$uid'; "; $result = mysqli_query($dbc, $query); if (mysqli_affected_rows($dbc) == 1) { // Insert subtotal $query = "UPDATE orders SET total=((SELECT SUM(quantity*price_per) AS subtotal FROM order_contents WHERE order_id=$oid) + $shipping) WHERE id=$oid"; $result = mysqli_query($dbc, $query); if ($result) { // get the value of total amount and order id $query = "SELECT total FROM orders WHERE id=$oid"; $result = mysqli_query($dbc, $query); list($order_total) = mysqli_fetch_array($result); $_SESSION['order_total'] = $order_total; $_SESSION['order_id'] = $oid; } else { // could not retrieve the order ID and total unset($cc_number, $cc_cvv, $_POST['cc_number'], $_POST['cc_cvv']); trigger_error('Your order could not be processed due to a system error. We apologize for the inconvenience.'); } } } else { // The add_order() procedure failed unset($cc_number, $cc_cvv, $_POST['cc_number'], $_POST['cc_cvv']); trigger_error('Your order could not be processed due to a system error. We apologize for the inconvenience.'); } } }
  5. Hi, Antonio After reading your reply, I tested the script. As you said, the sql is wrong and it returns a message : Error Code: 1327. Undeclared variable: subtotal. So I adapter your method, replace the INTO with AS, and the script is fully functional now. Thank you very much for pointing out.
  6. Hi, Larry In page 294. I try to break down the add_order procedure into separated piece since my shared host doesn't support routine. The problem lies in the last two statement. I believe the subtotal is a temporary column to store the result of quantity * price_per and then deal with the UPDATE statement that comes after. So, what's the best way to rewrite those two statements as normal sql query? I personally try to combine those two queries since they should work as one: $query = "UPDATE orders SET total=((SELECT SUM(quantity*price_per) INTO subtotal FROM order_contents WHERE order_id=$oid) + $shipping ) WHERE id=$oid"; Do you think this gonna work?
  7. Hi, Larry. Here is update. I have applied for a dream host account and moved the tutorial project into the web host. So I can continue to follow the book. The question for now is that do I required to sign up for a security certificate as well? Because in the figure 6.9 you used https to redirect the user, can I just use normal http instead of https?
  8. Hi, Larry. I stock in page 159 when I need to supply the 'cancel' and 'finish' URL after customer cancel or finish the transaction. Knowing that I work on this example store in my localhost mamp server, and I don't have SSL in the localhost server. What's the option under this situation? Can I supply http://localhost:8888/pdf_store/cancel.php ? or I will need to signup for a web host to do lesson in this chapter? Thank you
  9. Hi, Larry, The .col-3 and .col-9 in header doesn't position the list content correctly in my computer. the content list in .col-3 just went straight through entire page horizontally, and content that has .col-9 stacks below it. I changed to .col-md-3, and .col-md-9 seem fix the problem...
  10. In page 99, session_regenerate_id() cause en error "Cannot regenerate session id - headers already sent". If i comment this function out, everything goes fine. Where I should check for problem? thanks
  11. I tried to copy your create table users script and past into Terminal and get the exactly error. Please help
×
×
  • Create New...