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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow Stripslashes command - how do I implement it? (Probably a really easy question!)

    Hi,

    I'm an extreme novice with PHP so please forgive my lack of knowledge!

    I've done a script which basically writes what has been written into a textbox into a file (textfile.htm). However, I get backslashes ("\") all over the place. I know the command I need is "stripslashes", but I'm not entirely sure how to implement it.

    Here is the code for the page where the file is written from:
    PHP Code:
    <?php if ($action == "submit"){ $file fopen("textfile.htm""w"); fwrite($file$textboxfclose($file); } else { ?>

    <form action="?" method="post"> <input type="hidden" name="action" value="submit" /> <input type="text" name="textbox" /> <input type="submit" value="Submit" /> </form> <?php ?>
    And here is the code for the page where textfile.htm is included:

    PHP Code:
    <?PHP include("textfile.htm"); ?>
    Basically, therefore, my ultimate goal is just for the page where the file is included to not have slashes all over it and I was wondering how I'd go about doing this

    Thanks very much!!

    Chris
    Last edited by chris_denman; 06-25-2006 at 01:59 PM.

  • #2
    Regular Coder
    Join Date
    Sep 2005
    Posts
    394
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Replace the include with an fread...

    Code:
    <?php
    // get contents of a file into a string
    $filename = "textfile.htm";
    $handle = fopen($filename, "r");
    $contents = fread($handle, filesize($filename));
    fclose($handle);
    
    //echo out the text file with slashes removed
    echo stripslashes($contents);
    ?>
    ~Phil~

  • #3
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Thanks very very much!

    Quote Originally Posted by lavinpj1
    Replace the include with an fread...

    Code:
    <?php
    // get contents of a file into a string
    $filename = "textfile.htm";
    $handle = fopen($filename, "r");
    $contents = fread($handle, filesize($filename));
    fclose($handle);
    
    //echo out the text file with slashes removed
    echo stripslashes($contents);
    ?>
    ~Phil~
    Hi,
    Thanks very much... I'd thought I might need to reprocess it as a variable on the include page but wasn't sure how to go about it!

    Chris

  • #4
    Regular Coder
    Join Date
    Sep 2005
    Posts
    394
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Welcome


  •  

    Posting Permissions

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