function addVote($pUserId,$pVisteIp,$pVoteTime)
        {
             if(!checkVote($pUserId,$pVisteIp,$pVoteTime))
                    return false;
               
               $sql="insert into vote set user_id='$pUserId',vister_ip='$pVisteIp',vote_time='$pVoteTime'";
               $this->mDB->query($sql);
               $this->mDB->getInsertId ();
               return ture;
        }
这样试试

解决方案 »

  1.   

    return ture;
    错了
    return true;
      

  2.   

    加个return true;楼主把你的mysql这个类帖出来看看吧,学习一下
    $this->mDB = new mysql;
      

  3.   

    class.mysql.php<?
    // class.mysql.php
    //
    // class MySQL
    {
    var $mDBId;
    var $mLink; function MySQL ($i = "0")
    {
    $this->mDBId = $i;
    $this->mLink = -1;
    } function getLink ()
    {
    if (-1 == $this->mLink || !$this->mLink)
    {
    global $array_db;
    $this->mLink = mysql_connect ("cndb", "temp", "temp");
    mysql_select_db ("temp", $this->mLink);
    } return true;
    }

    function query ($pSql)
    {
    $this->getLink ();
    return mysql_query ($pSql, $this->mLink);
    }

    function fetchArray ($pResult)
    {
    return mysql_fetch_array ($pResult);
    }

    function getInsertId ()
    {
    if (-1 == $this->mLink)
    return false;
    else
    return mysql_insert_id ($this->mLink);
    }

    function getNumRows ($pResult)
    {
    return mysql_num_rows($pResult);
    }
    }
    ?>
      

  4.   

    现在的问题时:
    只有当表vote中没有记录时,addvote()才会执行,怎么回事?
      

  5.   

    $vote_time= date(" Y-m-d, h:i:s"); // 这个在显示时没有问题
    但是在插入时是错误的格式,建议
    $sql="insert into vote set user_id='$pUserId',vister_ip='$pVisteIp',vote_time=NOW()";
                   
      

  6.   

    $sql="select * from vote where vister_ip='$pVisterIP' and user_id='$pUserId' and vote_time> date_sub(now(),interval 1 day)";估计是你这个语句返回了值大于0了同一IP和ID 24小时只能投一次
      

  7.   

    function addVote($pUserId,$pVisteIp,$pVoteTime)
            {
                 if(checkVote($pUserId,$pVisteIp,$pVoteTime))
                 {               
                     $sql="insert into vote set            user_id='$pUserId',vister_ip='$pVisteIp',vote_time='$pVoteTime'";
                   $this->mDB->query($sql);
                   $this->mDB->getInsertId ();
                   return true;
                }
                else
                {
                     return false;
                 }
            }
      

  8.   

    你的表中有没有
    unique key (index)之类的唯一性索引,如果有可能是因为你的插入值重复,这个重复很可能是插入了空值,这个空值可能是数据无效造成的