Re: Wrighting to $_POST array
| From: | Jay Ess | Date: | Mon, 12 Oct 2009 15:17:45 +0000 |
| Subject: | Re: Wrighting to $_POST array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-298860@lists.php.net to get a copy of this message | ||
hessiess@hessiess.com wrote:
I have some code which will loop over the whole $_POST array, runs it through mysql_real_escape_string and then writes it all back to the array again, which seams to work. Are there any incompatibility problems or such like with writing into the $_POST or $_GET array?There could be problems when introducing slashes if you use other peoples codes. But if this is for your own code it probably wont matter. And here is a shorter version of your code : foreach($_POST as $key=>$val) $_POST[$key] = mysql_real_escape_string($val);function clean_post() { $npost = array();while ($value = current($_POST)) { $key = key($_POST); $npost += array("$key" => mysql_real_escape_string($value)); next($_POST); }$_POST = $npost; }