JREAM Posted April 27, 2009 Share Posted April 27, 2009 Is there a faster way to apply "mysql_real_escape_string" through the Posts of a form? Because Im going to have to insert these a LOT `title`='".mysql_real_escape_string($_POST['title'])."', `content`='".mysql_real_escape_string($_POST['content'])."', `public`='".mysql_real_escape_string($_POST['public'])."', Quote Link to comment https://forums.phpfreaks.com/topic/155793-loop-_post/ Share on other sites More sharing options...
mikesta707 Posted April 27, 2009 Share Posted April 27, 2009 yes foreach($_POST as $post){ $post = mysql_real_escape_string($post); } that should do what you want. Hope that helps! Quote Link to comment https://forums.phpfreaks.com/topic/155793-loop-_post/#findComment-820095 Share on other sites More sharing options...
JasonLewis Posted April 27, 2009 Share Posted April 27, 2009 Except put it back into a new array with the key as well. So it's basically the same as the $_POST array. $data = array(); foreach($_POST as $key => $value){ $data[$key] = mysql_real_escape_string($value); } Quote Link to comment https://forums.phpfreaks.com/topic/155793-loop-_post/#findComment-820111 Share on other sites More sharing options...
avvllvva Posted April 27, 2009 Share Posted April 27, 2009 <?php if(!empty($_POST)) extract(mysql_real_escape_string($_POST)); ?> If this will work, it maybe the easiest way...... Quote Link to comment https://forums.phpfreaks.com/topic/155793-loop-_post/#findComment-820112 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.