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 Quote 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 Quote 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? Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.