I have this php code to get the fields from a table
$id = $_GET['idd'];
$userip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']);
// do some validation here to ensure id is safe
$link = mysql_connect("localhost", "root", "");
mysql_select_db("veet");
//check if ip record is in DB
$sql_ip = "SELECT id FROM ip_address_list WHERE ip=$userip";
$result_ip = mysql_query("$sql_ip");
if (mysql_num_rows($result_ip) > 0) {
echo "Ip is already in database";
//
}
else {
echo "Ip is not in database";
//put ip to database and vote
}
and the query returns an error so i get the "mysql_num_rows() expects parameter 1 to be resource". If i change the WHERE ip=$userip"; to WHERE id=$id"; it works. Do you have any idea what might be the problem with the column ip??
EDIT: Because of the repost thingi. i am not asking how to deal with a false return I am asking why it returns false response. The sql query looks 100% correct to me.