Hi,
I've searched about on this forum for the past hour and have found lots of responses about this, but have to apologise for not getting my head around it!
I'm writing an appraisal system for the company I work for, and have been coding it for (wait for it) the past 11months. Checking recently, the system consists of over 466 pages, and from coding from scratch, weighs a nice 3.6MB.
It's written in PHP5, with HTML etc... and the only massive difference is that I'm using a Microsoft SQL backend, instead of MySQL.
The system is in the final stages, and in testing this week, the first thing someone tried to do on the update section was to enter an apostrophe, which completely cattled the submit code, they put 'logic' in which was highlighted in the error.
I've looked about, and saw there is the mysql work around, as well as a couple of others but I can't quite get my head around it.
Here's a quick look at how it works.
Edit page has text boxes on.
1 of the text boxes is called appAttendanceComment, it is pre-populated with the database entry for that field, so users can edit it. eg;
<textarea name="appAttendanceComment" cols="70" rows="4" id="appAttendanceComment"><? print $Row['appAttendanceComment']; ?></textarea>
The edit page posts to a php update form, and is collected like this;
@$appAttendanceComment = addslashes($_POST['appAttendanceComment']);
When then goes to the query;
@Query =
"UPDATE dbo.appraisal
SET appAttendanceComment = '$appAttendanceComment', (bla bla bla) WHERE appID = '$appID'";
The code works a treat when the boxes don't have apostrophes in them, but bombs out the second they are in, also, if the box already includes a \ or " it keeps adding slashes to it everytime it is updated.
My head is (just a little) blagged with it and I'd love it if you can help with some wise words to help get the system out and about and the manager of the project off my back!