note 49664 deleted from function.mysql-escape-string by danbrown

From: Date: Wed, 12 Aug 2009 21:49:17 +0000
Subject: note 49664 deleted from function.mysql-escape-string by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-159411@lists.php.net to get a copy of this message
Note Submitter: ---- Here's the solution I came up with for unescaping. I'm not a "real" programmer so there's probably some huge problem with this. I've been using it for a while and it seems to work okay though. function escape_string($string) { $string = nl2br($string); if(version_compare(phpversion(),"4.3.0")=="-1") { $string = mysql_escape_string($string); } else { $string = mysql_real_escape_string($string); } return $string; } function unescape_string($string) { stripslashes($string); $string = str_replace('<br />', Chr(13), $string); return $string; }

« previous php.notes (#159411) next »