Jump to content
Larry Ullman's Book Forums


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by Larry

  1. I would also double-check that you're running/editing the file you think you are (this chapter has multiple versions of register.php). And if it's still not obvious what's going on, please confirm your PHP version and OS. Oh, and when mentioning errors it's best to include the specific error that you're seeing. Thanks!
  2. Yes, the code in the book does work. I used it while writing the book and for all the images I took. I'm a bit confused by what you're saying in this last post, though. I just downloaded the script from the site and ran it again, unedited. Here is the initial load: And after clicking "Register" without entering anything: I'm not seeing a parse or other error.
  3. Yes, the code in the book does work. I used it while writing the book and for all the images I took. I'm a bit confused by what you're saying in this last post, though. I just downloaded the script from the site and ran it again, unedited. Here is the initial load: And after clicking "Register" without entering anything: I'm not seeing a parse or other error.
  4. Hmmm... I don't see anything obviously wrong. That normally means there's a gremlin character in there, like a straight quote that's actually curly or the like. These aren't as easy to debug. I'd try retyping or copying-pasting the first few lines (from a clean source). Otherwise you'll need to debug backwards to find the exact line causing the problem. For example, if you remove line 10 (which you can do here without causing a new parse error), does the current error go away?
  5. 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
  6. 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.
  7. 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!
  8. 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.
  9. 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)
  10. 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.
  11. It looks like the function is defined twice in the same file, starting on lines 28 and 33.
  12. 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.
  13. 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.
  14. 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.
  15. 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.
  16. 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.
  17. 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!
  18. Hmmm...this is the kind of thing that may change in different versions of MySQL. Nice work switching to using the + INTERVAL syntax, though!
  19. Could you confirm what the FULL URL is with Books & DVDs?
  20. 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!
  21. Try escaping the % sign. That's often the solution in situations like this, where a character may have special meaning.
  22. 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.
  23. Excellent. Thanks for letting me know and kudos!
  24. 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.
  • Create New...