我有这个PHP代码来从表中获取字段
$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
}
并且查询返回错误,因此我得到了"mysql_num_rows() expects parameter 1 to be resource"
。如果我将WHERE ip=$userip";
更改为WHERE id=$id";
则可行。你知道列ip ??