Jump to content
Larry Ullman's Book Forums

Larry

Administrators
  • Posts

    5413
  • Joined

  • Last visited

  • Days Won

    155

Posts posted by Larry

  1. 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. 

  2. 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?

     

  3. 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?

  4. 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!

  5. On 8/30/2019 at 2:08 PM, questomni said:

    Chap 10. Script 10.1 - view_users.php
    Line 5, 6, and 7 of source code.
    $row['last_name'] turns into "view_users.php?sort=ln" in
    the source code. I don't understand how the info is obtained other than this is how a query works. view_users.php is where the query is made. Yet, it accessed the users table in the database. Is "view_users.php?sort=ln" the $results showing?

    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. 

    On 8/30/2019 at 2:08 PM, questomni said:

    Is the query using the get method to supply the
    requested info, since there is no form suggesting it's a
    post method?

    Yes!

    On 8/30/2019 at 2:08 PM, questomni said:

    Also, The error_log says that:

    include(includes/footer.html): failed to open stream: No
    such file or directory.

    If you're getting that error, you're missing the includes/footer.html file in your web directory.

    On 8/30/2019 at 2:08 PM, questomni said:

    I noticed there's no HTML header file that is suppose to
    be included in the example file package, yet, the page is
    presented in source code.

    The URL to access it is clearly .php, so how is it I'm
    getting to see the source code?

    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. 

  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. The differences between the two queries are pretty obvious but what's really important is:

    1. What's the users table definition look like?
    2. 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. 

  8. 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...