Jump to content
Larry Ullman's Book Forums

Ch.12 - Error On 12.6? Need Help..


Recommended Posts

So I wrapped up 12.6, 12.7, 12.8 and went to try out and test and had some issues.

 

I found an error and fixed it in the code to where I could get the "delete post" to work.  My "edit post" part isn't working however.

 

I started looking at the code and comparing in the book, and then noticed that 12.5 (pg 353) and 12.6 (pg 359) code mysteriously changed where it shouldn't have changed:

 

12.5 code:

if ($_SERVER['REQUEST_METHOD'] == 'POST') {   //Handle the form

When you get to 12.6 (pg 359) it only says that the "mysql_real_escape_string"portions should be changed, however the code on 12.6 changes to (on the same line):

if (isset($_POST['submitted'])) {    //Handle the form


Why did this change and which version is correct?

 

Will this make the "edit post" link not work?

 

 

 

Link to comment
Share on other sites

  • 2 weeks later...

To add detail, PHP has a series of global arrays for HTTP request. $_POST is filled with POST data, $_GET with GET and $_REQUEST is a combination of them both. $_REQUEST is thus the least explicit of them of them all, and that's why you need to check if the request method is POST first. When you deal with just POST request, ($_POST) you already know that. It is therefor considered "cleaner" or more specific.

Link to comment
Share on other sites

To add detail, PHP has a series of global arrays for HTTP request. $_POST is filled with POST data, $_GET with GET and $_REQUEST is a combination of them both. $_REQUEST is thus the least explicit of them of them all, and that's why you need to check if the request method is POST first. When you deal with just POST request, ($_POST) you already know that. It is therefor considered "cleaner" or more specific.

 

Thank you for the further explanation of the above..  Makes sense now!  Appreciate it.

Link to comment
Share on other sites

Sorry about the confusion. Actually the code from Script 12.5 is what should be in there, but the code in Script 12.6 as written will work, too. The Script 12.5 approach is just cleaner, is all. 

 

Thank you for your reply Larry.

Link to comment
Share on other sites

I ended up scrapping everything (code) and starting over at the beginning of the chapter, and I'm glad I did - everything made more sense the second time around.  1 more chapter to go (working on it now!) then off to PHP and MySQL for dynamic websites.

Link to comment
Share on other sites

 Share

×
×
  • Create New...