SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Apr 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    cURL, str_replace and textarea

    Hello there,

    I am having a headachingly but a relatively simple problem which i cannot solve. I am using cURL to gather html code from a given URL.

    In one window, I am placing the code in a textarea and after submitting the form with the textarea in it (without making any changes) I put the code into a file.

    In another window, I am cURL'ing the data straight to the file.

    Though, the amount of characters is different.
    Through textarea: 103,055
    Without textarea: 100,825

    How can this be? I've tried str_replace function to remove \n or \r or \t characters or trim() the second file, but it resulted, of course, in even less characters.

    The problem is, the system is much more difficult than this, but this part is not changed. I need the second file (without textarea) to be exactly, byte to byte, the same as the first one, without using textarea. How can I achieve this?

    Thank you in advance.

    forgot to mention that I am using $html = htmlentities($htmlcode, ENT_QUOTES, 'UTF-8', true); and I am displaying the $html variable in the textarea. But after the form has been submitted, I check the code and it is decoded, but maybe textarea displays the code somewhat different than it would be just cURL'ing. And then after submission the character count gets different or something. I don't really know.
    Last edited by donkapone; Apr 25, 2009 at 06:16. Reason: forgot to mention htmlentities()

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Is magic_quotes on, by any chance?

    Look through both files, and try to spot any differences. I'm assuming the problem is that your PHP engine is adding slashes to quotes and backslashes etc before it gets to you, so try running the textarea's version through stripslashes, to see if that's your problem.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Member
    Join Date
    Apr 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, magic_quotes is not on. I am using WampServer 2.0 with default settings, by the way.

    You see, the funny thing is, that the textarea's version works as it should, and the one that does not use it doesn't work.
    I've tried using this tool: quickdiff dot com to see the differences, but it doesn't recognize any of them. I cannot spot them either with my naked eye. Though, there is, quite a substantial difference.

  4. #4
    SitePoint Member
    Join Date
    Apr 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I used stripslashes($_POST['html']); like so to see if there's a problem here. The idea is, the textarea's version shouldn't work after using stripslashes, if there's a problem here, right? But it does work. It only return the file 1 character smaller.
    Last edited by donkapone; Apr 25, 2009 at 06:40. Reason: character count

  5. #5
    SitePoint Member
    Join Date
    Apr 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    basically what I'm saying is that it works with this file
    abaldai dot lt slash failas dot html
    and it doesn't work with this one
    abaldai dot lt slash failas2 dot html

    How is this possible?


Tags for this Thread

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
  •