Mattmueller Posted November 4, 2013 Share Posted November 4, 2013 When doing the if else for the gender at steps 5, 6 and 7 he writes that the code should go if (isset($_REQUEST['gender'])) {$gender = $_REQUEST['gender']; if ($gender == 'M') {$greeting = '<p><b>Good Day, Sir!</b></p>';} elseif ($gender == 'F') {$greeting = '<p><b>Good Day, Madam!</b></p>';} else {$gender = NULL; echo '<p class="error">Gender Should be either "M" or "F"!</p>';} else {$gender = NULL; echo '<p class="error"> You forgot to select your gender!</p>';} Yet when you look at the example code in 2.4 it is written as: if (isset($_REQUEST['gender'])) {$gender = $_REQUEST['gender']; if ($gender == 'M') {echo '<p><b>Good Day, Sir!</b></p>';} elseif ($gender == 'F') {echo '<p><b>Good Day, Madam!</b></p>';} else {$gender = NULL; echo '<p class="error">Gender Should be either "M" or "F"!</p>';} else {$gender = NULL; echo '<p class="error"> You forgot to select your gender!</p>';} I seem to have missed why there is the difference in the two examples. Is one right and not the other? Does it matter which way you do it? Am i just totally over looking something? Wondered if i could get any help. Link to comment Share on other sites More sharing options...
Larry Posted November 4, 2013 Share Posted November 4, 2013 Hmmm...I don't have the book on me, so I can't confirm what's going on. Are you saying the code in the script is different than the code in the steps? If so, that's my mistake and I'll need to correct it. Link to comment Share on other sites More sharing options...
Mattmueller Posted November 6, 2013 Author Share Posted November 6, 2013 I am not an expert or anything but i have the ebook on my computer and the two codes above are the two codes given. The one with "$greeting" is how you say to do it in step 6 and the one with "echo": is what the example shows. There is a possibility I am wrong, I am not rulling that out, but I wanted to know what i am missing. Link to comment Share on other sites More sharing options...
Larry Posted November 6, 2013 Share Posted November 6, 2013 It's probably a mistake on my part. I fly home tomorrow and will double check this and then get back to you. Sorry for the confusion. Link to comment Share on other sites More sharing options...
Larry Posted February 7, 2016 Share Posted February 7, 2016 The errata has been updated to note that echo $greeting; is missing from Script 2.4, but it is in Step 8 on page 52 and in the downloadable code. Link to comment Share on other sites More sharing options...
Recommended Posts