dennismonsewicz Posted February 6, 2009 Share Posted February 6, 2009 when using the mysql_real_escape_string you don't have to use strip_slashes do you? The escaping the string handles all of that correct? Link to comment https://forums.phpfreaks.com/topic/144092-solved-mysql_real_escape_string-question/ Share on other sites More sharing options...
wildteen88 Posted February 6, 2009 Share Posted February 6, 2009 No you don't have to use strip_slashes after the use of mysql_real_escape_string. However before running mysql_real_escape_string you should first run strip_slashes encase magic quotes is enabled. Forexample function makeSafe($data) { // undo magic_quotes if(get_magic_quotes_gpc()) $data = strip_slashes($data); return mysql_real_escape_string($data); } // example usage $myName = makeSafe($_POST['my_name_field']); Link to comment https://forums.phpfreaks.com/topic/144092-solved-mysql_real_escape_string-question/#findComment-756037 Share on other sites More sharing options...
flyhoney Posted February 6, 2009 Share Posted February 6, 2009 Right Maybe an example will help. <?php $string = "Something's that's need's escaping"; $query = "UPDATE table SET string = '" . mysql_real_escape_string($string) . "'"; $result = mysql_query(); $query = "SELECT string FROM table"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); echo $row['string']; // Something's that's need's escaping ?> If you are using mysql_real_escape_string to build your quere Link to comment https://forums.phpfreaks.com/topic/144092-solved-mysql_real_escape_string-question/#findComment-756039 Share on other sites More sharing options...
dennismonsewicz Posted February 6, 2009 Author Share Posted February 6, 2009 cool i appreciate it... so what exactly does the mysql_real_escape_string() function do? as far as securing the post vs using strip_slashes? Link to comment https://forums.phpfreaks.com/topic/144092-solved-mysql_real_escape_string-question/#findComment-756041 Share on other sites More sharing options...
flyhoney Posted February 6, 2009 Share Posted February 6, 2009 mysql_real_escape_string escapes characters by adding slashes, it's similar to addslashes, but smarter. Link to comment https://forums.phpfreaks.com/topic/144092-solved-mysql_real_escape_string-question/#findComment-756044 Share on other sites More sharing options...
dennismonsewicz Posted February 6, 2009 Author Share Posted February 6, 2009 ah gotcha! Thanks yall! Link to comment https://forums.phpfreaks.com/topic/144092-solved-mysql_real_escape_string-question/#findComment-756049 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.