Hi,

Does anyone know of a nice (simple) script and / or tutorial on how to handle saving quotes to the database and displaying them on screen - one that is compatible on all systems no matter if magic quotes are on or off?

I'm looking at using such a script that will be compatible with my sites. I'm use to developing on a server with magic quotes on however now I'm working on a system where they are off. I'd like to make code that will work on both.

Thanks.

    mmm...

    I usualy have this one:

    if(get_magic_quotes_gpc()==1){ 
    //Everything is ok,
    }
    else{
    $PF2=$_POST; 
    foreach($_POST as $key =>$v){
    $PF2[$key] = addslashes($PF2[$key]);
    }
    $_POST=$PF2;
    $PF2=$_GET;
    foreach($_GET as $key =>$v){
    $PF2[$key] = addslashes($PF2[$key]);
    }
    $_GET=$PF2;
    }
    
    

    I would love comments on this one btw...

      I use this as an include. Don't recall where I got it from, perhaps the manual comments.

      <?php
      function strip_magic_quotes($arr) {
      	foreach ($arr as $k => $v) {
      		if (is_array($v)) {
      			$arr[$k] = strip_magic_quotes($v);
      		} else {
      			$arr[$k] = stripslashes($v);
      		}
      	}
      
      return $arr;
      }
      
      if (get_magic_quotes_gpc()) {
      	if (!empty($_GET))     { $_GET     = strip_magic_quotes($_GET);     }
      	if (!empty($_POST))    { $_POST    = strip_magic_quotes($_POST);    }
      	if (!empty($_REQUEST)) { $_REQUEST = strip_magic_quotes($_REQUEST); }
      	if (!empty($_COOKIE))  { $_COOKIE  = strip_magic_quotes($_COOKIE);  }
      }
      ?>
      
        Write a Reply...