Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hey Larry. First of all, loved this book so far. Already read the intro php book and am almost finished with this one, moving on to Effortless E-Commerce and your advanced php(latest edition) and javascript books to be released later this year. I hate that my first post here had to be a report of an error with your code but on page 563, on the footer.html file, line 17:

 

if ($_SESSION['user_level'] == 1)) {

 

It throws an error for an undefined index. A quick google search shows this fixes the problem:

 

if (isset($_SESSION['user_level']) && ($_SESSION['user_level'] == 1)) {

 

The first code assumes it's set, and if you first log on, and have no user level, it throws an error.

 

Also, for anyone seing the logout links instead of the registration links when you are first testing the site, check your cookies from past chapters and clear them for the site 'localhost' since some of the cookie/session names Larry uses are re-used in later examples, and they'll already have values. Not Larry's fault, as in a real world site, you would use common cookie/session names for different sites.

Link to comment
Share on other sites

Thank you very much for the nice words and the interest in my other books! As for this issue, the code does assume that the user_level is set, however, that code is within a conditional that checks if $_SESSION['user_id'] is set, so that's the check (because if $_SESSION['user_id'] is set, then $_SESSION['user_level'] will also be set, unless, as you found, you had previous cookies existing on localhost). Never hurts to be overly cautious, though!

Link to comment
Share on other sites

Ah, so the issue was not with the script, but that I had a user_id value in my cookies from a previous chapter script but no user_level value(0 or 1). I would imagine this would be an easy thing to avoid in a real world script where not everything comes from the site localhost :) . Thanks for the explanation.

 

I wanted to take the opportunity to say how much I love your writing style. There are MANY php books, and many are formatted horribly(more the publishers fault) or by the time you reach later chapters, the author assumes you've become a master programmer and stops explaining each step. I love how even in the last chapter, you still explain what each step is. You don't dwell on it, but you say what's going on AND you seam to know when a user might have forgotten a particular subject, and point back to the chapter where that topic is discussed more in depth. So: Thank You!

Link to comment
Share on other sites

Well, for what it's worth, it would be marginally better to add isset() to the user_level check, just in case.

 

Anyway, thank you very much for the very nice words. I'm glad that you like my work and it's kind of you to say so. I particularly appreciate the specific feedback of what you thought worked. A lot of credit goes to these forums, where I'm able to learn what works and what doesn't for the various readers. Thanks again!

 

What specific Giants are you a fan of, by the way? NFL? MLB? Actual mythological giants?

Link to comment
Share on other sites

While I am partial to various cyclops throughout history, I am a SF Giants fan.

 

I do have one more question: On page 627, you reference a $_POST['existing'] variable on line 138(or is it technically a string... I get my terms mixed up sometimes lol), but I do not see one set or mentioned anywhere in the form, not even a hidden value like $_POST['submitted'] is often set. Where is $_POST['existing'] set in the script? Thanks

Link to comment
Share on other sites

 Share

×
×
  • Create New...