Here's my problem:
I have a list of filenames stored in a text file, names.txt. My script reads the first filename, and then pulls that file from a remote site.
After grabbing the file, the script processes it a bit before looping back to the top to read the next filename in names.txt.
If I comment out Section A (see code snippet) and manually assign one filename to $name, everything works fine. However, when leaving Section A in the script, it throws this error:
"Warning: fopen(http://www.exampleSite.com/name.csv) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404"
If I put the URL into my browser, it works fine.
Completely baffled.
Any help please?
Code: Select all
// Section A ----- Reads all filenames from list
($nameHolder = fopen("names.txt", "r")) or die("Error opening names.txt");
while (!feof($nameHolder)){
$name = fgets($nameHolder);
//Grabs data from website
$url = 'http://www.exampleSite.com/'.$name.'.csv';
$handle = fopen("$url", "r");
/* Section B -----
A 'while' loop follows that writes the contents of the remote csv to a local file,
and then writes some of the data to a database.
Now the script loops back to the top to grab the next file name in the names.txt list.
*/
AT