mr_tobacco — 2013-10-10T13:07:50-04:00 — #1
I'm trying to get the script to connect to a txt file, open it, get first line of text in txt file, then turn it into a variable, once it has the variable $url it is then placed into the file_get_content(), the finish product should then shoots out onto the page. My host allows fopen content so it can't be that. The url is correct as I tested with typing it in fully in file_get_content but if it's a variable in it's place like file_get_conent($url) I get this error. Perhaps it's adding something when I fetch the first line in the file I really don't see how since it's a text file and I haven't added anything else except three lines of text.
Warning: file_get_contents(http://some_web_url.php ) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in
// opens temp data file
$fetch_url = file('http://website.com/example.txt');
// fetches first line: $fetch_url;
$url = $fetch_url;
$file_string = file_get_contents($url);
I just don't understand why this darn thing an't workin. :nono:
droopsnoot — 2013-10-11T05:30:45-04:00 — #2
Have you examined the contents of $url to see whether it is as you expect? Also I note that if the url contains any 'special' characters it must be encoded, though I assume you'd have had the same problem when you typed it directly. Can you show the contents of the file here?
michael_morris1 — 2013-10-11T15:53:19-04:00 — #3
A common security setting prevents the fopen family of functions (of which file_get_contents is a member) from opening remote files. It is advised that you leave the setting alone and use cURL.
Here's information on the setting.
You have been warned.