GhosteX Posted July 8, 2010 Share Posted July 8, 2010 So I'm using a form, kind of like the one I'm using right now, to insert data into a MySQL database, then display that data on the page, kind of like what will happen when I hit the "Post New Topic" button.Thing is, I get an error if that form data has quotations since the data itself is in quotations. When there is a quotation MySQL thinks that's where the query ends. If I switch to apostrophes, I get the same thing only with apostrophes. Is there a way to allow quotes in a form post without it causing errors? I can of course use entities or forward slashes but once the data is inserted, and I want to edit it, the data I get back has the actual quotations and apostrophes and I have to change it all again before re-submitting.The fact that I'm using quotes and apostrophes in this form right now mean I know this is possible. Any ideas? Thanks in advance.Here's a sample of the code.The query.$sql = "UPDATE $_POST[selecttable] SET priority=\"$_POST[editpriority]\", menu=\"$_POST[editmenu]\", content=\"$_POST[editcontent]\" WHERE menu = '$_POST[menulist]'"; The form.<textarea rows="20" cols="60" name="editcontent"> <?php echo $content; ?> </textarea> <p><input type="submit" name="Button" value="Edit"></p> Link to comment Share on other sites More sharing options...
thescientist Posted July 8, 2010 Share Posted July 8, 2010 that's part of the game. escaping them and then converting them back (or string replacing them). Shouldn't be too hard, that's the handy part about scripts, you just have write it do that and then it will do it from then on. Link to comment Share on other sites More sharing options...
real_illusions Posted July 8, 2010 Share Posted July 8, 2010 Have a look at this handy little thing:http://php.net/manual/en/function.mysql-re...cape-string.php Link to comment Share on other sites More sharing options...
GhosteX Posted July 9, 2010 Author Share Posted July 9, 2010 Thanks real, that works perfectly! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.