无法弄清楚这段代码有什么问题,但它没有为$ result返回任何内容:
// check to see if user has already voted
$current_user = $_SERVER['REMOTE_ADDR'];
$select_query = "SELECT * FROM w_poll_counter WHERE user_IP = " . $current_user;
echo $select_query;
$result = mysql_query($select_query);
echo $result;
if($result)
{
//user already voted - show results page
header("Location: show_results.php");
exit();
}
echo语句用于调试目的,一旦我(或你已经!)解决了这个问题,它就会被删除。 echo $ select_query正在返回该变量我的预期,但echo $ result根本没有返回任何内容。我可以在测试期间从同一个IP地址投出多个投票。这是不可取的!
请帮忙!
由于
答案 0 :(得分:0)
尝试正确引用您的查询
$select_query = "SELECT * FROM w_poll_counter WHERE user_IP = '" . $current_user ."';";