Jump to content
Larry Ullman's Book Forums


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About dmx1

  • Rank
  1. Hi Larry, Happy New Year! Hope you had a great festive season! Larry, I am still learning php and mysql, so please forgive me if the questions seem really basic, but I've tried to research and understand certain concepts, but I'm still confused. My understanding of foreign keys in a database is that: 1) They provide referential integrity. 2) It is used to link two tables together. 3) It will ensure that a table referencing another table will always be referencing a row that exists in its own table, and a table will never be orphaned. Now in your book: 'PHP and MySQL for Dynamic Web Sites' which I purchased recently. On page 198, you created a foreign 'customer_id' key in the 'accounts', table that references the 'customers' table. I understand this concept and it makes sense. But on page 170 in the 'Effortless E-Commerce' book, you again, created a foreign 'customer_id' key in the 'orders' table that references the 'customers' table on page 169. So you have different methods and approaches in both books, but they do the same thing! I'm really confused by this because i'm thinking: 1) How can the foreign 'customer_id' key in the 'orders' table, on page 170('Effortless E-Commerce'), reference the 'customers' table without explicitly referencing it like how you did it on page 198 in the 'PHP and MySQL for Dynamic' book? 2) I've never seen a foreign key get created in this way on page 170 in 'Effortless E-Commerce' book, so can you explain to me i) How this works, ie, how does the database knows 'customer_id' is a foreign key, and that it is referencing the 'customers' table on page 170, without you explicitly writing it. I looked in phpmyadmin, and looked in the designer veiw of your database, but there are no links or relationships demonstrated, or shown between any of the tables, even though the diagram on page 167 in the 'Effortless E-Commerce' book, clearly states that there a one-to-many relationship between the tables. 3) So why doesn't the tables in the Ecommerce2 database in phpmyadmin (in the designer veiw, or even in the database tables), not reflect or show the one-to-many relationships that you have stated exists between the tables on page 167. Thank you in advance regards
  2. Hi Larry, On page 168 in the first version of your ecommerce book, you said that you won't have a login form, like the first project. You also said that there will be no session id's, and instead by storing the customer's shopping cart contents and wish-list items in the database, the customer can leave and return and still have the previous actions recorded and available without ever logging in. My query is, "the customer can leave and return and still have the previous actions recorded and available without ever logging in", only applies if the customer is returning to the same computer, and taking into account that nobody else has used the same computer to add products to their own wishlist or shopping cart. Whereas with a login form, all the user has to do is login with their details, and all of their personalised information, ie saved shopping carts, will automatically return, regardless of how many users have used the same computer to browse and store their own items in their own shopping carts, and their saved history can be accessed remotely. Also, if the user goes to a completely random computer, their saved shopping cart or wish list items will not be visible or recorded. They will only be visible or recorded from the computer where they saved their items, and that's considering no one else has overridden their saved items, by adding their own. So: 1) Is their a way that a user's shopping cart and wish list history can be saved, and re-called from any random computer, and not be overridden if someone else decides to use the same computer to store their own items, because I want an amazon style shopping cart where the user can access their saved shopping cart and wish list history from any computer. 2) If the answer is no for question 1, how hard would it be to implement the login form from the 1st project into the 2nd ecommerce project? I hope my understanding is correct. regards Devon
  3. Larry, Thank you for this! I now understand. For some reason, I thought that $live was automatically changed from false to true, from some other part of the code in the application. I didn't realise I had to manually change the $live constant myself. Now onto understanding the rest of the code......Here goes!
  4. Hi Larry, Thanks for your quick response. I think the logic is my main issue here. So this is my understanding: (!$live) means NOT False, which in turns means TRUE. So on page 61 'if (!$live)' means if($live is NOT False) ie TRUE then do whatever............... This is where I had problems understanding what was going on. So my understanding now is; if (!$live) evaluates to True, then $live must still be False, which in turn means that it is still in development mode and not live. If (!$live) evaluated to False, this would mean that $live would be True, which would mean the site is live. I hope my understanding is correct, because it took me pacing up and down for a good while to understand what is going on. My Final questions is: QU 1: When the site does indeed go live, on what page in the book, or where in the script does TRUE get assigned to the $live variable to signify a change from development to live mode? QU 2: How does the site know when it indeed does go live? QU 3: What piece of code is used to see if the site is live, and where does this code reside? Hope the above made sense. Thanks Larry
  5. Hi Larry, Newbie questions: On page 60, I am getting slightly confused. $live is set to False 1) So in effect is this saying that we set the $live variable to False, so this equates to the site not being live(production mode), but in development mode(localhost)? Now on page 61 it says: if(!$live) Since $live is set to False in the config file, !$live equates to True(1), because NOT false is True. 2) So does 'if (!$live)' equate to: if(true == true) because (!$live) == !FALSE == TRUE 3) How does the site detect if it is live(in production mode) or in development mode(localhost)? So let me know if my understanding of what you wrote is correct. On page 60 i. You set $live to False to indicate that the site is not live ii. If the site is live, or in production mode, $live is set to True, which is represented in the else statement on page 61 4) Where does it then assign True to $live if the site is in production mode? Sorry for the basic questions, but I am still learning. Thank you
  6. Hi, I am a newbie, so please excuse any simple errors I may be making. The address for my php site is: http://localhost:8888/headbands1/ All my files are in the 'headbands1' root directory, such as the 'include', 'views', 'shop', 'sales', index.php. I have a file called '_.htaccess.txt' also in the 'headbands1' directory. I don't know if I really need to include the '_.htaccess.txt' file or not. It has the following information in it: <IfModule mod_rewrite.c> RewriteEngine on # For sales: RewriteRule ^./shop/sales/?$ sales.php # For the primary categories: RewriteRule ^./shop/([A-Za-z\+]+)/?$ shop.php?type=$1 # For specific products: RewriteRule ^./browse/([A-Za-z\+\-]+)/([A-Za-z\+\-]+)/([0-9]+)$ browse.php?type=$1&category=$2&id=$3 # For HTTPS pages: RewriteCond %{HTTPS} off RewriteRule ^./(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://%{HTTP_HOST}/$1 [R=301,L] </IfModule> When I click on an image, on the home page, I get an error saying: 'The requested URL /shop/sales/ was not found on this server.' The shop.php and sales.php pages have not been edited in any way. Can you tell me what I can do, so when I click on the 'Sales Item' image, on the home page, I will not get the above error, and it will take me to the correct page. Thanks