Magic Quotes and Strip Slashes: What am I doing wrong?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

eabigelow
Forum Newbie
Posts: 16
Joined: Thu Apr 24, 2008 7:06 am

Re: Magic Quotes and Strip Slashes: What am I doing wrong?

Post by eabigelow »

I tried turning off magic quotes at the beginning of this process--no go there! (I tried it again with the latest code (above), but still the same problem: third item in array of four still showing slashes).

Thanks, though!
eabigelow
Forum Newbie
Posts: 16
Joined: Thu Apr 24, 2008 7:06 am

Re: Magic Quotes and Strip Slashes: What am I doing wrong?

Post by eabigelow »

Thanks for the posts, but still working on this...

Here is the current code on the add.phtml file:

Code: Select all

<?php
 
 function unmagicquotes($string) {
     return function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()
         ? stripslashes($string)
         : $string;
}
 
if (isset($_POST["message1"], $_POST["pseudo1"], $_POST["pseudo2"], $_POST["pseudo3"])) {
     $message1 = unmagicquotes($_POST["message1"]);
     $pseudo1 = unmagicquotes($_POST["pseudo1"]);
     $psuedo2 = unmagicquotes($_POST["pseudo2"]);
     $pseudo3 = unmagicquotes($_POST["pseudo3"]);
  
     $filename ="msg.dat";
    $file= fopen($filename,'a');
     fputs($file, "$message1 - $pseudo1 - $pseudo2 - $pseudo3\n");
     fclose($file);
 }
  
 ?>
With this code, I am getting the slashes stripped from the first two and last one of the four items in the array. The third item (pseudo2) still has slashes...

Any advice, anyone?

Many thanks!
eabigelow
Forum Newbie
Posts: 16
Joined: Thu Apr 24, 2008 7:06 am

Re: Magic Quotes and Strip Slashes: Problem solved!

Post by eabigelow »

Many thanks, tasairis--There was a typo, but now it works. Like a dream! Again, many thanks!
Post Reply