Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bloomin Magic Quotes!

Status
Not open for further replies.

youradds

Programmer
Jun 27, 2001
817
0
0
GB
Argh..this is really getting on my nerves. I've tried disabling 'Magic Quotes' from my script with set_magic_quotes_runtime(0); at the top of my script..but that didn't work. I've also tried replacing all \" and \' with just " and ', but that doesn't want to work! Can anyone see why the code below will not replace the \" and \' chars?

$new = ereg_replace('\\"', '"', $line);
$new = ereg_replace("\\'", "'", $new);

Thanks for anyone who can help..this is really getting on my nerves :(

Andy
 
why don't you just use the stripslashes() function? It's not a lie if YOU believe it ;-)
 
It doesn't work :( At least not in the code I used.

Thanks

Andy
 
Could you post more of your code so we can see where you are getting the \" and\'.
If its from something like a textfield input then use
$text=stripslashes($textfieldinput) ***************************************
Party on, dudes!
[cannon]
 
I've tried adding;

set_magic_quotes_runtime(0);

at the top of my script..

I've also got the following code to remove " and 's :(


Code:
// function for HTML
function set_message_cookie() {

// we have to set a cookie here, cos otherwise when we send the EMAIL later it screws up!

global $message, $debug;

if ($debug) { echo &quot;Calling set_message_cookie() sub... <BR>&quot;; }

$message_array = explode(&quot;\n,&quot;, $message);

foreach ($message_array as $line) {

  if (ereg(&quot;^<.+>.+&quot;,$line)) { 


        //$new = stripslashes($line);
        $new = ereg_replace('\\&quot;',  '&quot;', $line);
        $new = ereg_replace(&quot;\\'&quot;,  &quot;'&quot;, $new);
        $back_message .= $new;

  } else { 

     $back_message .= ereg_replace(&quot;\r&quot;,  &quot;<BR>&quot;, $message);

  }
}


//$message = ereg_replace(&quot;\r&quot;,  &quot;<BR>&quot;, $message);

$put = @fopen(&quot;message.txt&quot;, &quot;w+&quot;);
fputs ($put, $back_message);
fclose($put);
send_html_do();

}
 
OK, this will first remove the \ then the &quot; then the ' from the $line.

$new=ereg_replace(&quot;'&quot;,&quot;&quot;,ereg_replace('&quot;',&quot;&quot;,stripslashes($line))); ***************************************
Party on, dudes!
[cannon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top