0

I'm trying to get (with PHP) data from a remote text file. The URL of the file is website.com/page.php?info=someinfo. So it's not a .txt file, I don't know if that matters. The whole contents of the page are text, however. When looking at the source, there is no HTML, only plain text.

I've been trying to get the data using fopen() and fread(), and file_get_contents. However, both methods give me a screen filled with "404, object not found" errors, placed all over the place. Does anyone know how to solve this?

Thanks,

user1128582
  • 81
  • 1
  • 3
  • 1
    "404, object not found" errors, placed all over the place" You'll have to be more specific. Exactly what errors do you get? What code do you use? What research did you do? Your post is too vague. – user2428118 May 29 '12 at 13:50
  • 4
    Can You please provide us the real URL? Can You at least access it via browser? – shadyyx May 29 '12 at 13:51
  • Maybe its the content: `404, object not found`? – flowfree May 29 '12 at 14:01
  • Yes, I can access the URL via the browser. The 404 errors are placed in multiple frames. The error says (roughly translated): Object not found! The URL has not been found on this server. The link at [url]this page[/url] is wrong. Please notify the author. It's obvious that the URL can't be found at this server, since it's on a different sever.. – user1128582 May 29 '12 at 14:05

1 Answers1

0

"website.com/page.php?info=someinfo" is not a text file, this is an HTML stream.

If you want to sniff the html content resulting from the query to "website.com/page.php?info=someinfo" then you have to use file_get_contents only, not fread nor fopen.

Sebas
  • 21,192
  • 9
  • 55
  • 109
  • Thanks, I expected something like this. However, it doesn't work either. Using only $file = file_get_contents("http://website.com/page.php?info=someinfo"); echo $file;, I get the same error :( – user1128582 May 29 '12 at 14:41
  • you could try to use cURL as well: see this link http://davidwalsh.name/download-urls-content-php-curl – Sebas May 29 '12 at 14:58
  • Nope, but I got it to work with cURL somehow.. Anyways, thanks for all responses :) – user1128582 May 29 '12 at 15:03