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'])."', 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! 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); } 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...... Link to comment https://forums.phpfreaks.com/topic/155793-loop-_post/#findComment-820112 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.