DamienRoche Posted February 8, 2009 Share Posted February 8, 2009 I have a form that has several preset values using value=' or " within an input field. Problem is, if I use ', then I can't use ' within the value and same for ". I can't escape the output because it's useless with slashes in the value. I need it as it is in the database. Is there any way around this? #NO SLASHES - doesn't show anything between two ' ' or after 1. <input type="text" name="q" value='<?php echo $fetchq['q'];?>'/> #SLAHES - shows everything but obviously is escaped. <input type="text" name="q" value='<?php echo addslashes($fetchq['q']);?>'/> Any help is greatly appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/144299-solved-simple-but-frustrating-echoing-within-value-on-form/ Share on other sites More sharing options...
kenrbnsn Posted February 8, 2009 Share Posted February 8, 2009 You need to use the function htmlentities with the option ENT_QUOTES: <?php <input type="text" name="q" value="<?php echo htmlentities($fetchq['q'],ENT_QUOTES);?>"/> ?> Ken Link to comment https://forums.phpfreaks.com/topic/144299-solved-simple-but-frustrating-echoing-within-value-on-form/#findComment-757251 Share on other sites More sharing options...
DamienRoche Posted February 8, 2009 Author Share Posted February 8, 2009 Thank you so much. Wow, this is pretty basic stuff. I thought I'd mastered forms and echoing data. Just never really had to use it I guess. Good security measure as well. Thank you. Link to comment https://forums.phpfreaks.com/topic/144299-solved-simple-but-frustrating-echoing-within-value-on-form/#findComment-757255 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.