soccerjunki Posted April 16, 2012 Share Posted April 16, 2012 Hi, I'm creating a chat-box application and I'm trying to add IP bans, where the php code checks if the user is banned or not and then insert the chat, but even if the IP address is banned it will still insert the chat. $ipsql = mysql_query("SELECT * FROM bans WHERE ip='$user_ip'" or die (mysql_error())); $bancheck = mysql_num_rows($ipsql); if($bancheck <= 0){ $sql = mysql_query("INSERT INTO chats (user_ip, user_name, chat_body, date_time) VALUES('$user_ip','$user_name','$chat_body',now())") or die (mysql_error()); } Thanks, Soccerjunki Quote Link to comment https://forums.phpfreaks.com/topic/261025-why-wont-his-code-work/ Share on other sites More sharing options...
Muddy_Funster Posted April 16, 2012 Share Posted April 16, 2012 your query line is wrong: //$ipsql = mysql_query("SELECT * FROM bans WHERE ip='$user_ip'" or die (mysql_error())); should be: $ipsql = mysql_query("SELECT * FROM bans WHERE ip='$user_ip'") or die (mysql_error()); also have you checked the value in $bancheck to make sure it's what you think it should be? Quote Link to comment https://forums.phpfreaks.com/topic/261025-why-wont-his-code-work/#findComment-1337751 Share on other sites More sharing options...
soccerjunki Posted April 16, 2012 Author Share Posted April 16, 2012 Yea i have, and it worked Thanks alot man Quote Link to comment https://forums.phpfreaks.com/topic/261025-why-wont-his-code-work/#findComment-1337754 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.