php esacping single quotes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mudassar

    php esacping single quotes

    Hello

    I've been trying to figure this problem out for quite a while and I'm
    having no joy.
    I'll give you some background info, I'm creating a form and one of the
    fields in the form is a big text area that I want to use to write to
    a text file. This works fine but the problem is all the single quotes
    are get escaped with slashes.

    I want to write to the text file with out the quotes getting escaped,
    I've tried htmlentities but that doesn't seem to work.
    Here is a snippet of the code.

    $Desc_file = date("dmYHis");
    $Desc_new = htmlentities($d esc, ENT_QUOTES);
    $filePath = "/public_html/nsite/info";
    $WriteToFile = fopen("$filePat h/$Desc_file","w+ ");
    fwrite ($WriteToFile, $Desc_new);
    fclose ($WriteToFile);

    Any ideas would be fantastic Thanks in advance for your help

    Mudassar
  • Jon Kraft

    #2
    Re: php esacping single quotes

    mudassar@aircan dy.co.uk (mudassar) wrote:
    [color=blue]
    > I want to write to the text file with out the quotes getting escaped,
    > I've tried htmlentities but that doesn't seem to work.
    > Here is a snippet of the code.[/color]

    Er?? Your previous post (yesterday) has been answered.

    JOn

    Comment

    • Five Cats

      #3
      Re: php esacping single quotes

      In message <8609c64f.03121 00201.5f12df12@ posting.google. com>, mudassar
      <mudassar@airca ndy.co.uk> writes[color=blue]
      >Hello
      >
      >I've been trying to figure this problem out for quite a while and I'm
      >having no joy.
      >I'll give you some background info, I'm creating a form and one of the
      >fields in the form is a big text area that I want to use to write to
      >a text file. This works fine but the problem is all the single quotes
      >are get escaped with slashes.
      >
      >I want to write to the text file with out the quotes getting escaped,
      >I've tried htmlentities but that doesn't seem to work.
      >Here is a snippet of the code.
      >
      >$Desc_file = date("dmYHis");
      >$Desc_new = htmlentities($d esc, ENT_QUOTES);
      >$filePath = "/public_html/nsite/info";
      >$WriteToFile = fopen("$filePat h/$Desc_file","w+ ");
      >fwrite ($WriteToFile, $Desc_new);
      >fclose ($WriteToFile);
      >
      >Any ideas would be fantastic Thanks in advance for your help[/color]

      I *think* this will help:



      I realised I have the same problem with a particular page, but haven't
      tried the cure yet!
      [color=blue]
      >
      >Mudassar[/color]

      --
      Five Cats
      Email to: cats_spam at uk2 dot net

      Comment

      • Rahul Anand

        #4
        Re: php esacping single quotes

        mudassar@aircan dy.co.uk (mudassar) wrote in message news:<8609c64f. 0312100201.5f12 df12@posting.go ogle.com>...[color=blue]
        > Hello
        >
        > I've been trying to figure this problem out for quite a while and I'm
        > having no joy.
        > I'll give you some background info, I'm creating a form and one of the
        > fields in the form is a big text area that I want to use to write to
        > a text file. This works fine but the problem is all the single quotes
        > are get escaped with slashes.
        >
        > I want to write to the text file with out the quotes getting escaped,
        > I've tried htmlentities but that doesn't seem to work.
        > Here is a snippet of the code.
        >
        > $Desc_file = date("dmYHis");
        > $Desc_new = htmlentities($d esc, ENT_QUOTES);
        > $filePath = "/public_html/nsite/info";
        > $WriteToFile = fopen("$filePat h/$Desc_file","w+ ");
        > fwrite ($WriteToFile, $Desc_new);
        > fclose ($WriteToFile);
        >
        > Any ideas would be fantastic Thanks in advance for your help
        >
        > Mudassar[/color]

        Hi Mudassar,

        Here is the modified code to handle the escaped single quotes.

        // Start of Code

        $Desc_file = date("dmYHis");

        if (get_magic_quot es_gpc())
        $Desc_new = stripcslashes($ desc);
        else
        $Desc_new = $desc;

        $filePath = "/public_html/nsite/info";
        $WriteToFile = fopen("$filePat h/$Desc_file","w+ ");
        fwrite ($WriteToFile, $Desc_new);
        fclose ($WriteToFile);
        // End of code


        *Magic Quotes GPC* is a PHP_INI setting. When it is set ON all the
        single quotes coming from any form are escaped with character \.
        Default setting for the Magic Quotes GPC is ON.

        Hope it will help....

        -- Rahul

        Comment

        Working...