Jump to content
Larry Ullman's Book Forums

Larry

Administrators
  • Posts

    5413
  • Joined

  • Last visited

  • Days Won

    155

Everything posted by Larry

  1. I'm not quite following your question but the most important answer is an included file can only be included once.
  2. Thanks for the feedback and the nice words! I'll look into this and get it fixed.
  3. So, per the error message, the constants are defined in mysqli.php. When you see this error message, your script is either including that file for a second time or trying to define those constants despite the fact they're already defined in mysqli.php.
  4. I just emailed you the same code I linked above. What happens when you run this? Do you see any error messages? Your last three posts don't include any details.
  5. This is strange. There's nothing in your PHP code that would explain this. Could you confirm the exact sequence of events and the result? So you're on a page with what specific URL? And then you click what specific link (and what is that specific URL)? And then the resulting URL is what?
  6. I can email you the code but it'd be the exact same file downloaded from here: https://github.com/LarryUllman/phpmysqlvqp-5ed/blob/master/ch09/script_09_03/register.php What happens when you run this? Do you see any error messages? Your last two posts don't include any details. I can't speak for other writers, but the code in my books is generally not for illustration purposes. It worked when I wrote the book! However, code is not like a light bulb that can be screwed in in any socket (and even light bulbs vary quite a bit). Code runs within an environment; code that worked on one environment may not work on another, although PHP works across most environments well. You haven't yet said what version of PHP and OS you're using, which may shed some light on the issue. As a database expert, I'm sure you can appreciate this. I could do a MySQL 5.3 dump of a database that can't be imported into a MySQL 5.7 database, let alone a MySQL 8. That doesn't mean the dump was invalid, just that it won't work as-is for all situations.
  7. Hey Dr. Kalpesh! Thanks so much for sharing what you're doing. That's just so wonderful to hear! Kudos for that and for the work you're doing!!! Thanks, Necuima, for sharing the specific chapter. That code can be found at: https://www.larryullman.com/downloads/phpvqp2_scripts.zip
  8. Okay, your current rule is: RewriteRule ^browse/(coffee|goodies)/([A-Za-z0-9\%\+\-]+)/([0-9]+)/?$ browse.php?type=$1&category=$2&id=$3 That looks correct but PCRE can be tricky. Your error message is odd, though, making me think maybe there's another problem. Does the browse script work for other categories? Can you load browse.php directly (it'll probably give an error but it should still run)? What happens if you go to localhost/browse.php?type=goodies&category=Books+%26+DVDs&id=3 directly?
  9. 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!
  10. 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.
  11. 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.
  12. 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?
  13. 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
  14. 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.
  15. 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!
  16. 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.
  17. 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)
  18. 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.
  19. It looks like the function is defined twice in the same file, starting on lines 28 and 33.
  20. 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.
  21. 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.
  22. 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.
  23. 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.
×
×
  • Create New...