kfarrar Posted December 14, 2010 Share Posted December 14, 2010 I have various elements of a form template stored in the database. When i retrieve them with _fetch_object and then insert them into a different table the slashes get removed. I need the slashes intact because these are eventually read with eval(). Is there a specific field type I can use? How do i keep the slashes there? I need it to stay just like it is. I'm using PHP/Mysql I put this in: <table><tr><td width=\"658\" id=\"center\"><input type=\"text\" name=\"line_item[]\" value=\"$field1\" size=\"6\" maxlength=\"13\" class=\"Standard\" id=\"PageLine\" /><input type=\"hidden\" name=\"line_item[]\" value=\"$field2\" /><input type=\"hidden\" name=\"line_item[]\" value=\"$field3\" /><input type=\"hidden\" name=\"line_item[]\" value=\"$field4\" /><input type=\"hidden\" name=\"line_item[]\" value=\"$field5\" /></td></tr></table> Then when it gets retrieved and re-inserted I get this: <table><tr><td width="658" id="center"><input type="text" name="line_item[]" value="$field1" size="6" maxlength="13" class="Standard" id="PageLine" /><input type="hidden" name="line_item[]" value="$field2" /><input type="hidden" name="line_item[]" value="$field3" /><input type="hidden" name="line_item[]" value="$field4" /><input type="hidden" name="line_item[]" value="$field5" /></td></tr></table> Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted December 14, 2010 Share Posted December 14, 2010 What do your INSERT and SELECT queries look like? Have you done any stripslashes()? Have you used mysql_real_escape_string(). Quote Link to comment Share on other sites More sharing options...
kfarrar Posted December 14, 2010 Author Share Posted December 14, 2010 I havn't done any stripslashes() and I have not used mysql_real_escape_string(). Here is how I get and re-insert: $elements = mysql_query("SELECT * FROM form_elements"); $element = mysql_fetch_object($elements); if (isset($_POST['page'])) { mysql_query("INSERT INTO auto_save (line_order, form) VALUES ('$count', '$element->page')"); } Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted December 14, 2010 Share Posted December 14, 2010 So if after your select the slashes are still there, then do this to insert: mysql_query("INSERT INTO auto_save (line_order, form) VALUES ('$count', '" . mysql_real_escape_string($element->page) . "')"); Quote Link to comment Share on other sites More sharing options...
kfarrar Posted December 14, 2010 Author Share Posted December 14, 2010 Thanks I'll give it try! Quote Link to comment Share on other sites More sharing options...
kfarrar Posted December 14, 2010 Author Share Posted December 14, 2010 I tried this on a couple of the INSERT statements and it looks like that did the trick! Thank's! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.