graham23s Posted July 1, 2008 Share Posted July 1, 2008 Hi Guys, i'm having a bit of trouble with the proper way to do this! i have a description field where users can write a description about themselves say: <?php $des = $_POST['description']; ?> i was wanting to write a small function to do all the usual stuff! stripslashes,nl2br etc but im not sure what i need to do in regards to making the input ready? i need new lines to be breaked instead of \n\r can anyone advise me on the functions i would need to make the input safe and ready! i know i need mysql_real_escape_string. cheers guys Graham Link to comment https://forums.phpfreaks.com/topic/112789-sorting-input-before-mysql-insertion/ Share on other sites More sharing options...
LooieENG Posted July 1, 2008 Share Posted July 1, 2008 mysql_real_escape_string(htmlentities($_POST['description'], ENT_QUOTES)) And when you output it, use nl2br($string) Link to comment https://forums.phpfreaks.com/topic/112789-sorting-input-before-mysql-insertion/#findComment-579304 Share on other sites More sharing options...
Barand Posted July 1, 2008 Share Posted July 1, 2008 Write to the db with the \r\n. That way you can can put it straight back into a textarea for later editing. As LooieENG said, only use nl2br when outputting to the page body. Link to comment https://forums.phpfreaks.com/topic/112789-sorting-input-before-mysql-insertion/#findComment-579383 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.