Jump to content

PHP/MySQL I Need Slashes Left In My Form Templates!


kfarrar

Recommended Posts

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>

 

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')");

}

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) . "')");

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.