Jump to content
Larry Ullman's Book Forums


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by 100yen

  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
  12. Hello Larry, Thanks for another great book. When I try to create users table for pdf store, I get an error: 'ERROR 1293 (HY000): Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause'. I tried couple times get the exactly same error. Is that mysql doesn't allow creation of two TIMESTAMP in two columns (date_created & date_modified) ?
  13. Hi, After following Larry's book and getting the helps from this forum, I finally get my first web project done. It has 4k product items and 1.5k users in the database. The website is fully functional in localhost. I carefully checked and killed all of bugs. Seems everything running without problem. So I need to looking into how to upload this project to the web host. I have never done anything like that before, so I am not sure what thing will go wrong and what things will screw up the project I have spent a year into. Please give some idea of what to avoid. I assume I just export the sql file from my local database and import it into web database with same name, and straightly upload all file in local host into web host. Change the BASE_URL value to web URL, and that will be all I need to do?
  14. Hi, Please give some thought of creating a Breadcrumb. Currently, I do Breadcrumb using basic logic that relays on the page title. for ex: <?php if($page_title == 'Categories' && isset($parent_id) && $parent_id == 0){ echo '<P>Home </P>'; } elseif ($page_title == 'Categories' && isset($level1)){ echo '<p><a class="link" href="index.php">Home</a> > '. $level1.'</p>'; } elseif ($page_title == 'Products'){ echo '<p><a class="link" href="index.php">Home</a> > <a class="link" href="index.php?cid='.$level1_id.'&c='.$level1.'">'. $level1 . '</a> > '. $level2 . '</p>'; } elseif ($page_title == 'Product Detail') { echo<<<EOT <p><a class="link" href="index.php">Home</a> > <a class="link" href="index.php?cid=$level1_id&c=$level1">$level1</a> > <a class="link" href="products.php?cid=$level2_id&c=$level2">$level2</a></p> EOT; } elseif ($page_title == 'New Arrival Products') { echo '<p><a class="link" href="index.php">Home</a> > New Arrival Products</p>'; } elseif ($page_title == 'Feature Products') { echo '<p><a class="link" href="index.php">Home</a> > Feature Products</p>'; } elseif ($page_title == 'Administrator Control Panel') { echo '<p><a class="link" href="control_panel.php">Control Panel</a></p>'; } elseif ($page_title == 'Account Overview'){ echo '<p><a class="link" href="account_overview.php">Account Overview</a></p>'; } I came across some goolge searches that I heard those expert developers using php object to auto create Breadcrumb in each page. Please give some ideas how those are done. Thanks in Advance!
  15. Hi, HartleySan, the script is fully work now after follow your instruction. Thanks. What I do is grabbing first option value and making an ajax call insert the handleResponse function of first menu. That solves the problem.
  16. Hi, HartleySan. Thanks for replying. yes, this thing can be confusing. But you are right about most of part until the second menu is populated. I want a feature similar to jQuery $('#second_select :first').click( ) that It asks the first<option> to run after it has been populated. Right now I have to pick an option inside the second <select> to make it run (which trigger the 'change' event). In short, I want a 'onload' event or something similar so when the second menu is loaded, and it run instantly. But as you mentioned there is no 'onload' event for select element, then any alternative solution?
  17. Hi, again. One more question: When I select a primary category from first <select> menu, the ajax response return and fill the sub category data into second <select>menu. When this happen, I expect the second <select> menu will automatically call ajax object to retrieve corresponding product data. However, it doesn't work that way. When the second menu loads, it doesn't do anything unless I expand the menu select a option, then it will retrieve the product. I realized that the reason being is I have only one event 'onchange' assigned to the event listener. So I modified my script to add multiple events: utility.addEvent(utility.$('sub_category_modal'), 'change', load_sub_cat); utility.addEvent(utility.$('sub_category_modal'), 'load', load_sub_cat); I add an event listener to watch for 'load' event so that when second <select> first load, it will trigger the same function of load-sub_cat to load subcategories. So far only the first 'change' event works. The second 'load' event doesn't work, I suspect the 'load' is not the correct type but I am not sure which one will work. Pleas again give some advise. thanks.
  18. Hi, here is another problem I would like to get a hint or some thought of it. I get a group a datas from ajax response that I would like to append them into existing product listing. // ajax response that I want to inside into the product listing page <div id="category_thumbnail"> <a href="product_detail.php?pid=<?php echo $products['product_id'] ?>"> <img src="<?php echo $products['file_url_thumb'] ?>"><?php icon($products); ?></a> <p class="p_sku"><a href="product_detail.php?pid=<?php echo $products['product_id'] ?>"> <?php echo $products['product_sku'] ?></a></p> <p class="p_name"><?php echo $products['product_name'] ?></p> <p><a class="d_delete" href="remove_product_mailer.php?pid=<?php echo $products['product_id'] ?>"></a></p></div> if do innerHTML, this group of data will be inserted but existing products data will be erased. If I use appendChild(), which doesn't work at all since this method only append single element. I checked W3C DOM guide and there is no a method similar to innerHTML but append the data instead of replace them. I have been going so far and this is last feature I need to make it work, so please give me any suggestion to work around this problem. thanks a lot!
  19. HartleySan, Finally I made the script work after reading your post. Thank you! It really helps a lot. All I do is move the product class selector inside the ajax.onreadystatechange() of the category block, so that when the category on change, the getElementsByClassName is able to capture the element I am looking for. if(utility.$('sub_category_modal')){ utility.$('sub_category_modal').onchange = function(){ var category_id = utility.$('sub_category_modal').value; ajax.open('get', 'get_products_ajax.php?cid=' + encodeURIComponent(category_id)); ajax.onreadystatechange = function(){ handleResponse_product(ajax); // add products if(document.getElementsByClassName("add_small")){ var add_product = document.getElementsByClassName("add_small"); for(var a = 0; a < add_product.length; a++){ add_product[a].onclick = function(){ var product_sku = this.parentNode.childNodes[1].textContent; ajax.open('get', 'update_newsletter_ajax.php?sku=' + encodeURIComponent(product_sku)); ajax.onreadystatechange = function(){ handleResponse_update_newsletter(ajax); } ajax.send(null); return false; } } } } ajax.send(null); return false; } }
  • Create New...