note 38230 added to function.mysql-real-escape-string

From: Date: Sat, 13 Dec 2003 00:12:45 +0000
Subject: note 38230 added to function.mysql-real-escape-string
Groups: php.notes 
Request: Send a blank email to php-notes+get-61881@lists.php.net to get a copy of this message
It appears as though mysql_real_escape_string doesn't get rid of mysql comments, i.e. '--'; I want it to do so, not for security issues but just to keep from having partially inserted data. So here's a function that uses a regular expresion to remove any multiple-hyphen substrings, as well as running mysql_real_escape_string: function escape_data($data){ global $dbc; $pattern='-{2,}'; $data=eregi_replace($pattern,'',$data); return mysql_real_escape_string($data,$dbc); } ---- Manual Page -- http://www.php.net/manual/en/function.mysql-real-escape-string.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38230 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38230&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38230&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#61881) next »