Results 1 to 7 of 7

Thread: Removing PHP-generated backslashes

  1. #1
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,395
    Thanks
    32
    Thanked 153 Times in 147 Posts
    Blog Entries
    34

    Default Removing PHP-generated backslashes

    Hello you PHP-gurus,
    I've put the following code on a page:
    Code:
    <?php
    $fn = "file.html";
    $file = fopen($fn, "r+");
    $size = filesize($fn);
    if($_POST['addition']) fwrite($file, $_POST['addition']);
    $html = fread($file, $size);
    fclose($file);
    ?>
    
    <form name="myform" action="<?=$PHP_SELF?>" method="post" target="frame">
    <div id="the_content" contenteditable="true" >
    <?=$html?>
    </div><br>
    <input type="text" name="addition" id="addition" style="display:none">
    </form>
    
    <button onmouseover="document.getElementById('addition').focus();document.getElementById('addition').value=document.getElementById('the_content').innerHTML" onmouseup="document.myform.submit();">Save</button>
    
    <iframe name="frame" style="display: none"></iframe>
    The code works fine. Whatever I write in the contenteditable div is saved and stored on the server.
    My problem is the behavior of one of my servers. Whenever I put something between quotes in the contenteditable div, it (the server) ads a backslash. I've googled around and tried all kinds of suggestions but without succes. Does anyone have a solution for this particular case?
    Thanks.

  2. #2
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    stripslashes()
    You never know everything, I learn everyday!

  3. #3
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,395
    Thanks
    32
    Thanked 153 Times in 147 Posts
    Blog Entries
    34

    Default

    Thanks.
    Yes, I know, but I don't know how to use it in my code, in this particular case.

  4. #4
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    PHP Code:
    stripslashes($html
    You never know everything, I learn everyday!

  5. The Following User Says Thank You to fastsol1 For This Useful Post:

    molendijk (07-24-2014)

  6. #5
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,395
    Thanks
    32
    Thanked 153 Times in 147 Posts
    Blog Entries
    34

    Default

    I already tried that in my php-code. No succes. Where in my code should I put it?
    Thanks.

  7. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,133
    Thanks
    44
    Thanked 3,229 Times in 3,190 Posts
    Blog Entries
    12

    Default

    Code:
    <?php
    $fn = "file.html";
    $file = fopen($fn, "r+");
    $size = filesize($fn);
    if($_POST['addition']) fwrite($file, $_POST['addition']);
    $html = fread($file, $size);
    $html = stripslashes($html);
    fclose($file);
    ?>
    Either that, or try turning off magic quotes on the problematic server.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. The Following User Says Thank You to jscheuer1 For This Useful Post:

    molendijk (07-24-2014)

  9. #7
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,395
    Thanks
    32
    Thanked 153 Times in 147 Posts
    Blog Entries
    34

Similar Threads

  1. Resolved Getting rid of backslashes
    By Anne Arbor in forum PHP
    Replies: 2
    Last Post: 01-23-2014, 04:00 AM
  2. Resolved [ask] code generated
    By madkixt in forum JavaScript
    Replies: 8
    Last Post: 11-24-2008, 10:54 AM
  3. CSS ignored by FF in PHP generated page
    By Strangeplant in forum CSS
    Replies: 1
    Last Post: 04-06-2008, 01:04 AM
  4. CSS Styling A PHP Generated Table
    By tomyknoker in forum PHP
    Replies: 4
    Last Post: 04-04-2007, 03:24 PM

Bookmarks

Posting Permissions

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