Jump to content
Larry Ullman's Book Forums

dmx1

Members
  • Posts

    70
  • Joined

  • Last visited

Everything posted by dmx1

  1. Hi Larry, I tried researching but I still don't fully understand the following lines of code on page 68 in the 2nd edition of Effortless Ecommerce: /// Create each menu item: foreach 1. foreach ($pages as $k => $v) { // Start the item: 2. echo ' <li ' ; //Add the class if it's the current page: 3. if ($this_page == $v) 4. echo ' class="active" ' ; // Complete the item: 5. echo ' ><a href= " ' . $v . ' "> ' $k . ' </a></li> ' ; // End of FOREACH loop. I understand that the foreach loop iterates through each page's key and value' I get confused at line 2: echo ' <li ' ; This displays the list item. Qu 1: The list item isn't completed, it's just an 'li' tag, so how do you print just a 'li' tag? Line 3 and 4 confuses me. if ($this_page == $v) echo ' class="active" ' ; You say if the current page is equal to it's value, then print the class with a value of 'active' Qu: 2 How do you print a class with a value of active? Can you explain how the echo statement prints a class with a value of active I looked inside the css stylesheet and there's no 'active' selector, so how does class='active' relate to the page's values? Line 5 prints the hyperlink. It prints the value and the associated key echo ' ><a href= " ' . $v . ' "> ' $k . ' </a></li> ' ; I don't understand how you constructed it in this way. Qu 3: What's the significance of the following snippet below, and why add in '>' . $v . ' "> ' $k . ' Thanks regards
  2. Also, why do you need to call the config.inc.php file in every page?
  3. Hi Larry, I'm a newbie so please forgive the basic questions On page 60, you wrote the code: if(!defined('LIVE')) DEFINE('LIVE', false); You said if you wanted to allow the live setting to be set on a single page, in order to debug that page, you would write: DEFINE('LIVE', true); require('./includes/config.inc.php'); I don't really understand this logic. If you wanted to debug a specific page, you would write on the specific page, DEFINE('LIVE', true); require('./includes/config.inc.php'); So 'LIVE' would be set to true, then the config.inc.php file would be called, but my confusion is: QU 1: After the config.inc.php is called, how would that debug the specific page in question ie, how would that then link back to the specific page you wanted to debug? Qu 2: In the above scenario, is the website initially offline, ie localhost, because 'LIVE' is set to false, and you have then changed 'LIVE' to true, in one page, in order to see how it operates in a live environment? Qu 3: Can you explain the process of setting 'LIVE' to true on one specific page ie, the config.inc.php file is called and............ Thank you. regards
  4. Thanks Larry! It sounds like a very tall order, especially for a newbie like myself, but I will definitely give it a go!! No doubt, I will run into problems where I will need your help, but I will exhaust every option before requesting your help! Thanks again!!
  5. Hi Larry, Hope you are well. Regarding the 1st edition of your ecommerce book: I am using the non coffee products concept(on page 198) in my own application because I want the user to be able to see a list of different products like on page 198, figure 8.6, when they choose a particular category. But what I want is for there to be a dropdown next to each individual product , like on page 219, (figure 8.15), that lists the different sizes available for each individual product, and everytime the user selects a different size, the price changes accordingly for that individual product. So basically, if we look at your application for example, when the user selects the 'GOODIES' tab, then selects the Mugs option, they are presented with a list of diffent Mugs they can buy, ie, 'Red Dragon', and 'Pretty Flower Coffee Mug'. Say now that each mug come in small, medium and Large sizes. i) would like for there to be a select dropdown next to each Mug option, that displays the different sizes available, just like in the coffee section, but I would like, when the user selects an option, say the large option for a mug, the price for the large mug will change accordingly, and thus be displayed alongside it, similarly an automatic price change for the small and medium mug options also. ii)I would also like to create a product_details page, so when the user clicks on say the 'Red Dragon Mug', they will be taken to a dedicated page that displays more details about the particular mug, giving them the option to add the mug to the shopping cart. iii) When the user goes to the shopping cart, I would like the size of the product to be displayed alongside each item, so the user can see exactly what size item they are purchasing. Please could you help me in achieving the three tasks above, because I have really tried, but I keep getting my code wrong. I'm still in the learning process, so I don't have enough knowledge and experience to implement exactly what I want. So I would really appreciate your help. Thank you!
  6. Hi Larry, In the first edition on page 334, there is a query: $q = '(SELECT CONCAT("O", ncp.id) AS sku, ncc.category, ncp.name, ncp.price, ncp.stock FROM non_coffee_products AS ncp INNER JOIN non_coffee_categories AS ncc ON ncc.id=ncp.non_coffee_category_id ORDER BY category, name) UNION (SELECT CONCAT("C", sc.id), gc.category, CONCAT_WS(" - ", s.size, sc.caf_decaf, sc.ground_whole), sc.price, sc.stock 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 ORDER BY sc.general_coffee_id, sc.size, sc.caf_decaf, sc.ground_whole)'; Now when I run this query, I get an error in my application. When I run the above query in phpmyadmin, it says that: 'Unknown column 'sc.size' in order clause' 1)There is not a 'size' column in the 'specific_coffees' (sc), table. So is 'sc.size' in the order clause, in the above query, a typo error? 2)If it is a typo, what should it be instead of 'sc.size'? regards
  7. Hi Larry, I've managed to sort the problem out now! It was really tricky because the files you used are years old, and I was using the current zend framework files, which didn't correspond to the code in your book. That's why I was having problems. I've reached the final.php page now. regards
  8. Hi Larry, I have a few questions for you regarding the zend mail installation. 1) Are there any step by step instructions on how to install the correct zend framework version that you use in the first edition of your book 2) Could you tell me what version of the zend framework you used in the first edition of the book. 3) Could you provide the link to the version you used in the first edition of the book so I can copy the correct files. 4) I downloaded the composer file and the zend framework 3, but the files don't seem to correspond to the code in the email_receipt.php page. That's why I think I have a different zend framework version from the one you downloaded. 5) I can't seem to find the location for: include ('Zend/Mail.php'); in zend framework 3 6) When you create the following line: $mail = new Zend_Mail(); what class are you referring to regarding the object creation, and where can it be located please. Thanks
  9. Hi Larry, I've sorted the problem now. Thanks
  10. Hi Larry, I have managed to get all the way, error free up to the billing.php page. When I get to the billing.php page and put in the values on page 306, and then try to process paymnet, I get an error saying: An error occurred in script '/Applications/MAMP/htdocs/billing.php' on line 161: Undefined offset: 3 The line it is referring to is in the billing.php page which is: $reason = addslashes($response_array[3]); I am not sure, but I think it may have something to do with the gateway_process.php page. When I debugged the file, I get an empty string, "" returned when I execute: $response = curl_exec($request); This line is located in the gateway_process.php page. I replaced all the https, with http, because I don't have an SSL certificate insalled yet. Can you help me fix the problem please. Thanks
  11. Hi Larry, I've got to say, I'm slowly losing patience with what I am trying to do. I have tried everything, and when I think I have solved it, the solved problem generates a new error! In the 'config.inc.php' file, the session_start() method is proving to be a problem. If I comment it out, then the login status is lost, when I go from page to page, which is not what I want. If I include it, the login stats works fine, but everytime I go back to the cart page from the checkout page by clicking the page back button, the url: http://localhost:8888/cart.php?action=add&sku=C11 is generated again, and whatever product is in the shopping cart, is increment by one, so if I have 1 item in the shopping cart, by clicking the back button from the checkout page, which takes me back to the cart page, the above url is sent back, and another item is added, so i would now have 2 items, which is not what I want. I want the same number of items to be in the shopping cart. So by clicking the browser back button from the checkout page, the url I should and want to get is: http://localhost:8888/cart.php and not the first url. This would mean that no extra items would be added in the shopping cart. I have tried everything possible, but I have literally run out of ideas. Qu: Can you please help me resolve the above problems please, because I'm really tired and fresh out of ideas. regards
  12. Hi Larry, To avoid the error: 'Cannot change session id when session is active.' when trying to navigating to the checkout page, you suggested I make every page call session_start() once? How would I make every page call session_start() once? I tried to use: if( session_id($uid)) { session_start(); } but the above method loses login status when I try to navigate to any random pages, just after I log in. regards
  13. Larry, before I saw your reply, I kinda found a way around the error message 'Cannot change session id when session is active' . when I navigate to the checkout page. What I did is put in the checkout page around the problematic line: if(!isset($_SESSION) { session_id($uid); ................................... } So this worked perfectly because the code session_id($uid); would only execute if no session had started. So now I can leave the session_start() method in the configuration file without any conflict when the checkout page is run. Please let me know if my above logic makes sense. regards
  14. Hi Larry, I think I have managed to sort out the problem regarding the the login status being lost when I go to the checkout page. Basically, I implemented the login functionality from the 1st project into the ecommerce site. Now in the config file for the 1st project, it contains the session_start() methhod. This starts the session and tracks logged in users. Now when I go to the checkout page, an error is generated on the following line: session_id(uid); The error says: 'Cannot change session id when session is active.' So because the session has already been started in the configuration file(from the 1st project), when it reaches the statement 'session_id(uid)' in the checkout page, an error is generated because the session is not supposed to be active at that point, but it is, because it's been started in the configuration file to track logged in users. To get around this error, I inserted a session_destroy() method in the checkout page just before session_id(uid); ie: session_destroy(); session_id(uid); and making it the first statement also in the checkout page in the else clause. } else { session_destroy(); session_start(); $uid = session_id This solves the problem, and I can now click on the checkout page without the error, 'Cannot change session id when session is active.' being generated. But the implication now is that, because session_destroy() destroys the session, the user's status is also affected, and hence the user being logged off. In regards to the 1st project, a session_start() method needs to be inserted in the configuration file in order to be available to all the pages, and to track the logged in user. But this is the line that is conflicting with the checkout page and generating an error, hence the session_destroy() being implemented to solve the problem. So I'm in a catch 22 situation now. The session_destroy() method solves one problem, but creates another, ie logs out the user. Qu 1: What solution can I implement to solve the above problem which will allow me to go to the checkout page without losing the login status, whilst allowing the session_start() method in the configuration file to track the logged in users? I find that when I comment out the session_destroy() methods in the checkout page and leave the session_start() method in the configuration file. I now navigate to the checkout page, and then by clicking the back button to go back to the cart page, this inadvertently increments the items in the shopping cart by 1. This is because the url: http://localhost:8888/cart.php?action=add&sku=C11 is being generated each time I go from the checkout page back to the cart page, I think!! Qu 2: What could I do to avoid this issue, so that the items in the shopping cart will remain constant and not be incremented each time I go from the checkout page back to the cart page? regards
  15. Hi Larry, The logged in status is lost when I press the back button to return from the checkout page to the cart page. 1) The cart page doesn't begin with https(but the checkout page begins with https), the cart page is just a normal http page I believe. So wouldn't the problem still exist, because I can't turn the cart page from http to https when it's supposed to be a normal http page. 2) I removed all the https and replaced them with http(for testing purposes), so I shouldn't be having the problem of losing status because I'm going from http to http, for the time being. Qu 1: If my above logic is correct, how would I resolve the issue of not losing the logged in status by travelling from the cart(http page) to checkout page(https page)? regards
  16. Hi Larry, I have managed to find a way to integrate your login form from the 1st section, with the ecommerce site in the second section, which seems to work ok, but there is a slight problem. Everytime I log in, then add items to the cart, then go to the chekcout page, if I decide I don't want to make a purchase at that point, and want to go back and browse more items, I am suddenly logged off. So basically, after logging in, everytime I go to the checkout page from the cart page, and then press the back link to go back to the carts page, I am automatically logged off, then I have to log back in again. So the current session and user credentials gets destroyed everytime I go to the checkout page, and I am then logged off. My question is: Qu 1: Is there a way that I can remain logged in after going to the checkout page, and then clicking the back button to go back to the cart page? Qu 2: Is there a way that I can remain logged in say for 15 minutes with no activity, and then automatically log out if the user hasn't reacted after 15 minutes? regards
  17. Hi Larry, I managed to solve the problem. The problem is when I integrate your login form with the ecommerce site, there is a conflict of code.
  18. Hi Larry, It seems it might have been a cache problem. I deleted the cache for my firefox browser. When I click the link in the 'cart' page to go to the 'checkout' page, I get an error saying: 'Cannot change session id when session is active Array' It is referring to the checkout.php page, and the line that is giving me the error is: // Use the existing user ID: session_id($uid); So I think by emptying the cache, I somehow deleted the cookies etc. Qu: Do you know how i would solve the above problem? regards
  19. Larry, I did what you suggested and removed all of the https links and changed them to http, but I am still getting the same error. Everytime I click on the 'checkout' link in the cart page, I receive an error. My url has the following code: https://localhost:8888/checkout.php?session=378f49d69df81eeb898f6b6a42fa96d5 I also then get the following error: "Secure Connection Failed An error occurred during a connection to localhost:8888. SSL received a record that exceeded the maximum permissible length. Error code: SSL_ERROR_RX_RECORD_TOO_LONG" So even though I changed all of the https and replaced it with http, I am still getting the same error. I have noticed that the url begins with https and not http, even though I have changed everything to http in the 'checkout', 'billing' and 'final', php and html pages. I have also removed the code from the .htaccess page that enforces SSL on those pages, and still no luck! Qu 1: Why does the url keep on starting with https and not http even though I have changed everything to http? Qu 2: Is there something I am missing, because I can't seem to find out the problem. regards
  20. I looked in your book, and I think I need to purchase a certificate first.
  21. Larry, I told you I'm a newbie!! Lol I haven't installed or configured any certificates. How would I go about doing that please?
  22. I am running macOS High Sierra version 10.13.6 on a macbook pro. I am running apache server.
  23. Hi Larry, I am trying to connect to the checkout.php page, by clicking on the 'checkout' button in the 'cart.php' page, but I get the following error: 'An error occurred during a connection to localhost:8888. SSL received a record that exceeded the maximum permissible length. Error code: SSL_ERROR_RX_RECORD_TOO_LONG The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.' I have tried using firefox and safari, and still run into the same error. Safari says it can't open the page because it can't establish a secure connection to the server "localhost". Qu: Do you have any idea what the problem might be and the steps I would take in order to solve the above issue please. Thanks
  24. Hi Larry, I wrote the following code: $r = mysqli_query($dbc, "CALL get_users_info_from_carts('$uid')"); if (mysqli_num_rows($r) > 0) { while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { if ($row['users_id'] == '0') { $usr_id = $_SESSION['user_id']; mysqli_query($dbc, "CALL add_user_to_cart('$uid', $usr_id, '$e')"); } } } The CALL add_user_to_cart('$uid', $usr_id, '$e') function is suppose to update the carts table, but for some reason, no update is happening. I ran the scripts directly through phpmyadmin and they are executing fine, but for some reason, the code above is not generating an update. mysqli_query() is not executing the stored procedure. Is there anyting that you see that may be a problem? Can you help please. Thanks
  25. What i am trying to do is when the user logs on, a query is run that returns his shopping cart items, and insert an his user_id and email address into the cart if their fields are empty. That way, we will be able to associate the user and his cart items. That's what i'm trying to implement in the login.inc.php script, but unfortunately, the code that I sent you is not allowing me to do that. $r = mysqli_query($dbc, "CALL get_users_info_from_carts('$uid')"); The above line should return all the cart items for the current user_session_id. The following line should retrieve all the names and values of the fields for each row. $row = mysqli_fetch_array($r, MYSQLI_ASSOC)) This is when the problem arises. Is there a better way of doing this?
×
×
  • Create New...