Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts

    It is automatically inserting slashes in front of " ?

    Hi guys.

    I have this script to post and saves contents to a .php file. However, if I try to add html to it, it will automatically insert slashes '\' in front of ' " '.

    How would I disable that behavior in order to be able to parse html to the file?

    PHP Code:
    <?php
    $saving 
    $_REQUEST['saving'];
    if (
    $saving == 1){ 
    $data $_POST['data'];
    $file "news.php"

    $fp fopen($file"a") or die("Couldn't open $file for writing!");
    fwrite($fp$data) or die("Couldn't write values to file!"); 

    fclose($fp); 
    echo 
    "Saved to $file successfully!";

    }
    ?>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Try
    PHP Code:
    $data get_magic_quotes_gpc() ? stripslashes($_POST['data'];) : $_POST['data']; 
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts
    Just gets this: Parse error: syntax error, unexpected ';' in C:\Documents and Settings\Kasper\Skrivebord\xampplite\htdocs\Hjemmeside\write.php on line 31


  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Oops, an extra semi-colon by typo, I think. Try
    Code:
    $data = get_magic_quotes_gpc() ? stripslashes($_POST['data']) : $_POST['data'];
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    CaptainB (05-15-2008)

  • #5
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts
    That worked! Thanks bud!

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Quote Originally Posted by CaptainB View Post
    That worked! Thanks bud!
    You are welcome, BTW, I'd recommend you to check what's/why get_magic_quotes_gpc() ,if you haven't done this
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •