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? Quote Link to comment 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']); Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted February 6, 2009 Author Share Posted February 6, 2009 ah gotcha! Thanks yall! Quote Link to comment 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.