pantinosm Posted May 20, 2011 Share Posted May 20, 2011 Hi to everyone. So, I have a little php code that reads line by line from a txt file, specifically i have 1 IP address for each line, and compares it with the current user's IP. It's like a little blacklist code. But it doesn't work. Can anyone see what i am doing wrong? $file = fopen("ipblacklist.txt", "r") or exit("Unable to open file!"); //Output a line of the file until the end is reached $ipblacklist=''; $refile=''; while(!feof($file)) { if (fgets($file)== $_SERVER['REMOTE_ADDR']) $ipblacklist='error'; $refile=fgets($file); } fclose($file); Thank you in advance Link to comment https://forums.phpfreaks.com/topic/236943-error-comparing-a-line-from-a-file-with-a-string/ Share on other sites More sharing options...
dreamwest Posted May 20, 2011 Share Posted May 20, 2011 http://www.wizecho.com/nav=php&s=files Link to comment https://forums.phpfreaks.com/topic/236943-error-comparing-a-line-from-a-file-with-a-string/#findComment-1217937 Share on other sites More sharing options...
pantinosm Posted May 20, 2011 Author Share Posted May 20, 2011 It reads it correctly but when it tries to compare with if (fgets($file)== $_SERVER['REMOTE_ADDR']), it seems like it doesn't work. Please, any suggestions? Link to comment https://forums.phpfreaks.com/topic/236943-error-comparing-a-line-from-a-file-with-a-string/#findComment-1217940 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.