Jump to content

Archived

This topic is now archived and is closed to further replies.

mazman13

Need help with \ being loaded before a '

Recommended Posts

I'm saving text to a TEXT file instead of a database, so if i use "" or '' to say something, PHP adds the \ before it.

I've tried the stripslashes($string) before it loads to the text file and when I call the info (not both at the same time)...but the \ is still there.

Any ideas?

Share this post


Link to post
Share on other sites
you may have added slashes twice to the database...
try

[code]$string=str_replace("\",'',$string);
echo $string;[/code]

that should do the job..


Liam

Share this post


Link to post
Share on other sites
[code]<?php

function magic_strip($str)
{
    if (get_magic_quotes_gpc()) $str = stripslashes($str);

    return $str;
}

$file = fopen('/path/to/file.txt', 'w');

frwite($file, magic_strip($_POST['text']));

fclose($file);

?>[/code]

Share this post


Link to post
Share on other sites
That script works. Thanks.

Can you explain it? I think I have an idea, but I just want to make sure.

Share this post


Link to post
Share on other sites
you only need to stripslashes() post data if magic_quotes are on :)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.