[thelist] Slashes Problem

Daniel Padolsky padolsky at gmail.com
Mon Sep 15 12:17:41 CDT 2008

When you are entering information into a form and posting it to have it
processed, do you only have to prep the $_POST part to get rid of the
slashes? I'm using the following function to prep my entries, but I'm still
seeing slashes. Any ideas why? On one page I enter the information in a
form, then press next and the info goes to the next page where it catches it
with "$quiz_title = mysql_prep($_POST['quiz_title']);". But then I send the
information back in a URL and catch it again on the other page with
"$quiz_title = mysql_prep($_GET['quiz_title']);". The information is sent
again back and forth (this time only using the URL get method), and whenever
I enter an apostrophe or quotation I get the slashes. I do this back and
forth thing so that I can keep the information consistent for the quiz. I
probably did this the hard way but it's my first time trying to do this and
don't know any better. Here's the function I'm using. I also notice that
everytime it goes back and forth between pages a slash is added, so I must
be missing something somewhere, but I don't know where to look. Thanks.
function mysql_prep( $value ) {
  $magic_quotes_active = get_magic_quotes_gpc();
  $new_enough_php = function_exists( "mysql_real_escape_string" ); 
  if( $new_enough_php ) { 
   if( $magic_quotes_active ) { $value = stripslashes( $value ); }
   $value = mysql_real_escape_string( $value );
  } else { 
   if( !$magic_quotes_active ) { $value = addslashes( $value ); }
  return $value;

More information about the thelist mailing list