XP is just a number | |
PerlMonks |
An exercise in mind readingby jarich (Curate) |
on Feb 23, 2004 at 07:36 UTC ( [id://331047]=note: print w/replies, xml ) | Need Help?? |
G'day bobafifi,
What you're really asking of us is for us to read your mind. There's a whole heap of information that you should have put into this question. This includes the following:
You can read more about what kind of information we like to see in questions over at our tutorials page. You've written this question assuming that we've already read the previous discussion from last week. If this question is entirely dependant on that discussion then this node should have gone into there, not created a new question. If this question is a new question then you need to write out all the relevant information (and only the relevant information) so that people like me can see everything I need here. Now that I've read last week's discussion I'll discuss what's happening in your code over here. Great, you connect to the database. You almost certainly want to add ShowErrorStatement => 1 in next to RaiseError. Code ugliness aside, what's happening here is that we're saving the current contents of $guestbookreal into @LINES. Now we're deleting everything from $guestbookreal and opening it for writing. This is just asking for 2 scripts to try to access the file at once, or any other of a myriad of problems. This code is generating SQL for all lines in $guestbookreal that contain the string "<!--begin-->" in them. Lines without that string are printed back into the $guestbookreal as they were previously. Once they're all printed back into the file the file is closed. This code then reads all the entries out of $guestbookreal, prepares them into one huge sql statement and executes that. I have no idea what should happen here as presumably your file contains more than one sql statement and I've never tried to do that with prepare. Nevertheless, the end result of this script is going to be to add everything already in $guestbookreal into the database (probably "again"). Because you've cut so much out of the main for loop I have no idea what specifically is wrong here. It appears obvious that the script is supposed to add your new entry (submitted from the guestbook form) into the $guestbookreal file as the first line. You seem to have lost the lines that would do that. You're trying to shoehorn a database onto code which is designed to store guestbook entries into a flat HTML file. I recommend that instead of generating your SQL and printing it to a file you consider rewriting this part of the script entirely. Perhaps you could replace everything from: to with: This at least would make sense. Once more I'll recommend that you change to using nms scripts rather than Matt Wrights'. As you've experienced in the past, Matt's scripts have a few security issues, and the hand-rolled CGI parameter parsing in the script I discuss here, makes me cringe. Good luck. jarich
In Section
Seekers of Perl Wisdom
|
|