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

From: Date: Tue, 13 Apr 2010 09:16:57 +0000
Subject: note 97301 added to function.mysql-real-escape-string
Groups: php.notes 
Request: Send a blank email to php-notes+get-168190@lists.php.net to get a copy of this message
This function can be changed to be suited for; $_GET, $_POST, $_SERVER, $_SESSION, $_COOKIE and others. However.. your return can only be 1 variable. So if you use $_GET //AND// $_POST, your return will be for ex: $array This will.. make a mess of things. This function is set for $_POST. I know this function can be changed, though I'm just a beginner :) <?php function clean($_POST, $a, $b) { if($a == '1') : $_POST = array_map('trim', $_POST); endif; if(get_magic_quotes_gpc()) : $_POST = array_map('stripslashes', $_POST); endif; $_POST = array_map('mysql_real_escape_string', $_POST); if($b == '1') : $_POST = array_map('ucwords', $_POST); return $_POST; endif; if($b == '2') : $_POST = array_map('strtolower', $_POST); return $_POST; endif; if($b == '3') : $_POST = array_map('strtoupper', $_POST); return $_POST; endif; } ?> The usage of this function, can be similar to this. <?php clean($_POST, 1, 1); ?> This will do a clean process of.. <?php ucwords(mysql_real_escape_string(trim($_POST))); ?> With stripslashes if the get_magic_quotes_gpc() if statement returns true. ---- Server IP: 92.48.74.199 Probable Submitter: 87.102.42.132 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-real-escape-string.php Edit -- https://master.php.net/note/edit/97301 Del: integrated -- https://master.php.net/note/delete/97301/integrated Del: useless -- https://master.php.net/note/delete/97301/useless Del: bad code -- https://master.php.net/note/delete/97301/bad+code Del: spam -- https://master.php.net/note/delete/97301/spam Del: non-english -- https://master.php.net/note/delete/97301/non-english Del: in docs -- https://master.php.net/note/delete/97301/in+docs Del: other reasons-- https://master.php.net/note/delete/97301 Reject -- https://master.php.net/note/reject/97301 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#168190) next »