Adding Quotes to input boxes
Posted: Fri Apr 08, 2005 7:49 am
I have a problem when a user enters quotes into my text boxes.
if the user submits the form with the title as eg 'hel"lo wo"rld' and i echo it on my page, it will echo correctly as 'hel"lo wo"rld'. however, if the user goes back into the form to edit the variable from the database, the value of the box is 'hel.
i have tried the following to get it to work, but it doesnt seem to help any.
prints out \'hel\ into the text box.
any help would be appreciated.. im still learning this php stuff 
if the user submits the form with the title as eg 'hel"lo wo"rld' and i echo it on my page, it will echo correctly as 'hel"lo wo"rld'. however, if the user goes back into the form to edit the variable from the database, the value of the box is 'hel.
i have tried the following to get it to work, but it doesnt seem to help any.
prints out \'hel\ into the text box.
Code: Select all
$q = mysql_query("e;SELECT title FROM inventory WHERE id=$id"e;) or die(mysql_error());
$data = mysql_fetch_object($q);
$title = addslashes($data->title);
<input type="e;text"e; name="e;title"e; size="e;35"e; value="e;<?= $title ?>"e; />