Jump to content
Larry Ullman's Book Forums

Larry

Administrators
  • Content Count

    5196
  • Joined

  • Last visited

  • Days Won

    143

Everything posted by Larry

  1. The "root" directory is the base or initial directory. In other words, when you unzip the file it creates a folder and when you open that folder, you're in the root directory. This is what the root directory looks like: https://github.com/LarryUllman/phpmysqlvqp-5ed The file you want is https://github.com/LarryUllman/phpmysqlvqp-5ed/blob/master/sql.sql
  2. You have a parse error in your script. This is normally caused by missing a matching parentheses, quote, bracket, or the like. It's possible it's on line 10 or, if not, then on a previous line but not triggered until line 10. If you need additional help identifying the problem, please post the actual code you're using.
  3. Thanks so much for the nice words. I really appreciate it. And it's great to hear you've been able to make great use of the information already! Thanks, too, for the suggestion. I thiiiiink I actually wrote such an example in one of my books, but I forget which now. Personally, though, I prefer to backup databases using the command-line tools, although that does require better access and knowledge. In any case, thank you again for the nice words and suggestion. Cheers!
  4. That's not what's happening. $row['last_name'] refers to a specific column from a returned row. The sort=ln bit is used in the code to dynamically change the ORDER BY clause. Yes! If you're getting that error, you're missing the includes/footer.html file in your web directory. I'm fairly sure there should be a header file, too. I'd double-check the book's directions. It may be re-using a header file from a previous chapter. If you're seeing the source code, it could be because you're not accessing the page through HTTP.
  5. You should debug the query itself to start. See if the query is returning exactly one row or not. If not, then you need to debug it backwards to see if the problem is: The value of $e in the PHP script The value of email in the database If active has a null value in the database (not an empty value)
  6. Hello! First, just so you know, these forums aren't that active. I check them three days a week myself. So going forward you should assume it'll take at least a couple of days to get a reply. As for your specific issue, I've been working with PHP for 20 years now and I've never heard of that error before. What is the exact URL you're loading when you see that error and what is the exact error? Finally, do keep in mind that this book assumes solid comfort with PHP and MySQL and builds upon that knowledge to create a couple of advanced e-commerce applications. If you're not truly comfortable with both technologies, you may want to start with a different book first.
  7. It looks like the function is defined twice in the same file, starting on lines 28 and 33.
  8. Saving the file and placing it in the web directory is the same instruction I've used since page 4. There's only the one file.
  9. The differences between the two queries are pretty obvious but what's really important is: What's the users table definition look like? What error message, if any, is MySQL returning. The answer to the first might inform the second, but you ought to just look at the MySQL error directly. That's assuming there is an error. If there is no error then your query is syntactically fine, there's just no matching rows.
  10. You shouldn't be storing the user_id in both a cookie and a session. Figure out which approach you ought to be using--cookies or sessions--and just go with that one.
  11. Well, the error means that it cannot find the named file or directory, which either means the file or directory doesn't exist OR the file or directory path provided is wrong. Here it's the latter. Note that you start with /~saphiakhara That's probably wrong. In Unix, the tilde refers to the current user's home directory. So ~ in this case equals /Users/saphiakharaz. You have "/~saphiakhara" which is incorrect in a couple of ways. "~/ecom1/..." would be more correct but you should probably use the full, absolute path ("/Users/saphia...") instead.
  12. I don't know where those values are coming from! I'd just search through your code to see where you might have defined them more than once.
  13. Ah, okay. This is definitely do-able, but not simple. To start, you'll need a way of reflecting sizes for non-coffees. An option would be to replicate the coffee database structure. Note that if somethings might have multiple sizes and other things might not, you'll need to account for that. For the automatic price change, you'll need to use JavaScript. When the size selection changes, the JavaScript would fetch the information for that size from another PHP script (using an XHR request). Or you could do some sort of logic where the display PHP stores the new price as metadata on the menu and then the JavaScript parses that out. In either case, you'll need to use JavaScript. For the product details page, follow the specific coffees page as a model, passing along the specific product ID and then fetching it from the database. For the shopping cart with a sized product, just replicate what's being done with the coffees. Let me know if you have any more questions and good luck!
  14. Hmmm...this is the kind of thing that may change in different versions of MySQL. Nice work switching to using the + INTERVAL syntax, though!
  15. Could you confirm what the FULL URL is with Books & DVDs?
  16. Yeah, this looks like a UTF issue. I'd make sure you have all that squared away, both in the database definitions and in the connections. Switching to English only may work but it entirely defeats the purpose of what you're trying to do here!
  17. Try escaping the % sign. That's often the solution in situations like this, where a character may have special meaning.
  18. The table structure I have in my SQL file is CREATE TABLE `specific_coffees` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `general_coffee_id` tinyint(3) unsigned NOT NULL, `size_id` tinyint(3) unsigned NOT NULL, `caf_decaf` enum('caf','decaf') DEFAULT NULL, `ground_whole` enum('ground','whole') DEFAULT NULL, `price` decimal(5,2) unsigned NOT NULL, `stock` mediumint(8) unsigned NOT NULL DEFAULT '0', `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `general_coffee_id` (`general_coffee_id`), KEY `size` (`size_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; where specific_coffees has a size_id column.
  19. Excellent. Thanks for letting me know and kudos!
  20. With XAMPP on Mac OS X, the root MySQL user password should be "root". If not that, then it's nothing (no password), which is totally fine while just starting on a local machine.
  21. The first edition is 9+ years old right now, so I'm not sure you should use that version of Zend, even if it's still available. It looks like Zend Mail is now installed via Composer: https://docs.zendframework.com/zend-mail/ Code examples for the current version of Zend Framework can be found here: https://docs.zendframework.com/zend-mail/message/intro/ Let me know if you need more help updating the book's example for the current version of ZF.
  22. Ah, sorry for the confusion. By putting fwrite() as the condition, it'll always be executed when the write() method is called. The condition then reacts based upon the result of the fwrite() call. Put another way: the fwrite() call is not being conditionally called; it's always called.
  23. I cannot give you any better answer without knowing how it's not working. What is it doing that it shouldn't be? What is it not doing that it should be doing? What debugging steps have you tried and what were the results? Just posting code and saying "I'm still having trouble to make it work" doesn't provide sufficient information.
  24. The "undefined offset" means you're referring to an index position that doesn't exist. In this case, there is nothing at $response_array[3]. You should look at what $response_array is--what values it has indexed at what positions--and what you're actually trying to do to figure out what the right change is.
×
×
  • Create New...