johnnyboy Posted November 15, 2007 Share Posted November 15, 2007 hello I get a parse error when I assign an external file to a variable. I deleted the entire file except <?php $lines = file('http://www.example.com/myfile.txt'); ?> I get Parse error: syntax error, unexpected T_VARIABLE in /home/restofpath/file.php on line 3 what gives, this example i took directly from the php manual any help appreciated johnny Quote Link to comment Share on other sites More sharing options...
johnnyboy Posted November 15, 2007 Author Share Posted November 15, 2007 by the way i am on php version 4.4.4 the server api is cgi if you need any other info let me know. Quote Link to comment Share on other sites More sharing options...
holladb Posted November 15, 2007 Share Posted November 15, 2007 what are you trying to do? grab the data?? can't really tell from the code Quote Link to comment Share on other sites More sharing options...
johnnyboy Posted November 15, 2007 Author Share Posted November 15, 2007 yes it is supposed to load the file into the variable the example can be found here http://uk3.php.net/file Quote Link to comment Share on other sites More sharing options...
pkSML Posted November 15, 2007 Share Posted November 15, 2007 PHP Manual: "You can use a URL as a filename with this function if the fopen wrappers have been enabled." Possibly you can't open a remote location. Try file_get_contents for the URL. Maybe the problem is related to the fact that 'http://www.example.com/myfile.txt' is a non-existent URL. Try a real URL. Quote Link to comment Share on other sites More sharing options...
johnnyboy Posted November 16, 2007 Author Share Posted November 16, 2007 pksml , thanks for the tips. I changed the url because i did not want to post it here, but the one I use is a real url. fopen works on my server, but I wanted to use file() ok, I apologize for this post because I fear that I have just been an idiot. there was a period in one of the blank lines that was causing the error it now works fine. thanks pksml Quote Link to comment Share on other sites More sharing options...
pkSML Posted November 16, 2007 Share Posted November 16, 2007 No problem. I didn't think PHP 4 was that much different from PHP 5! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.