H`i... I`m working on a members only site .... I want at login to check if an IP is banned or not ... for this I used the following syntax:
PHP Code:
$ip = getip(); //GET USERS IP
//Check IP bans
$nip = ip2long($ip);
$res = mysql_query("SELECT * FROM bans WHERE $nip >= first AND $nip <= last") or die(mysql_error());
//first and last are columns in bans table
if (mysql_num_rows($res) > 0) {
$row = mysql_fetch_array($res);
header("HTTP/1.0 403 Forbidden");
echo "<html><head><title>Forbidden</title></head><body><h1>Forbidden</h1>Unauthorized IP address.<br />".
"Reason for banning: $row[comment]</body></html>";
die;
}
If I try to access the site I receive the following error:
Code:
Mysql sintax error. Try to find corect sintax to use near 'SELECT * FROM bans WHERE $nip >= first AND $nip <= last'.
I`m using mysql-server-5.0 on a Ubuntu machine