如果row等于

时间:2014-04-20 22:56:04

标签: php

我试图在我的评级脚本上收到错误,当有人喜欢文章时,ip会进入数据库。这很好,但我不能从db等于检查IP。我需要收到一条消息,上面写着“你已经投票了'

<?php
$user = new User();
if($user->isLoggedIn())
{
    if (!empty($_SERVER['HTTP_CLIENT_IP']))
    {
        $ip=$_SERVER['HTTP_CLIENT_IP'];
        //Is it a proxy address
    }
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
    {
        $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
        $ip=$_SERVER['REMOTE_ADDR'];
    }

    //The value of $ip at this point would look something like: "192.0.34.166"
    $ip = ip2long($ip);
    $id = $row->id;

    // GET IP
    $q_50 = $db->query("SELECT INET_NTOA(ip) FROM vote WHERE cID = '$id'") or die($db->error);
    if($row_50 = $q_50->fetch_object());
    if($row_50->ip === $ip)
    {
        echo 'You already voted';
    }

0 个答案:

没有答案