note 96164 added to function.nl2br

From: Date: Thu, 11 Feb 2010 19:38:56 +0000
Subject: note 96164 added to function.nl2br
Groups: php.notes 
Request: Send a blank email to php-notes+get-165886@lists.php.net to get a copy of this message
A cluge hack for mysql_real_escape_string: If you have post data with /r/n and use mysql_real_escape_string to clean it, then try to use any function on this page, the function will show the stripped version of the break tag (not the html). Hack: <code> $myVar = $_POST['myVar'];//e.g. //replace post string with pipes $myVar = str_replace("\r\n", "||", $myVar); //clean $myVar = mysql_real_escape_string($myVar); //replace pipes with real break tags $myVar = str_replace("||", "<br>", $myVar); </code> I'm sure there is a much smarter way to do this! ---- Server IP: 69.147.83.197 Probable Submitter: 72.130.240.202 ---- Manual Page -- http://www.php.net/manual/en/function.nl2br.php Edit -- https://master.php.net/note/edit/96164 Del: integrated -- https://master.php.net/note/delete/96164/integrated Del: useless -- https://master.php.net/note/delete/96164/useless Del: bad code -- https://master.php.net/note/delete/96164/bad+code Del: spam -- https://master.php.net/note/delete/96164/spam Del: non-english -- https://master.php.net/note/delete/96164/non-english Del: in docs -- https://master.php.net/note/delete/96164/in+docs Del: other reasons-- https://master.php.net/note/delete/96164 Reject -- https://master.php.net/note/reject/96164 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#165886) next »