在MySQL console中执行:
mysql>update `1001` set finish=0 where sid=94664;
Query OK,1 row affected (0.07 sec)
Rows matched:1 changed:1 warnings:0php中的语句:$tid="`".$_COOKIE['uid']."`";
$which="finish=1";
$where="sid=".$sid;
$db=new Mysql("localhost","root","","members_check","","UTF8");
$db->connect();
$result=$db->update($tid,$which,$where);
echo $result;
//if($result){echo 0;}else{echo 1;}js那里返回来的就是空,什么都没有。用下面那个if语句返回不了0。但是数据库里全部操作成功。附上封装的函数:public function query($sql) {
     if ($sql == "") {
     echo "SQL语句为空";
     }
     $this->sql = $sql;
     $result = mysql_query($this->sql, $this->conn) or die('faill'.mysql_error());
     $this->result = $result;
     return $this->result;
}public function update($table, $mod_content, $condition, $url = '') {
     $result=$this->query("UPDATE $table SET $mod_content WHERE $condition");
     return $result;
}

解决方案 »

  1.   

    echo 用于输出字符串,而你的 Mysql::update()返回值是布尔值,因此 echo true;当然得不到任何东西。
      

  2.   


    我用if($result){echo 0;}else{echo 1;}的话,不返回0  
      

  3.   

    这是个奇怪的问题,以至于我很怀疑你描述的
    在代码后面加上一句 var_dump($result, mysql_error()); 贴出结果
      

  4.   


    <pre class='xdebug-var-dump' dir='ltr'><font color='#3465a4'>null</font></pre><pre class='xdebug-var-dump' dir='ltr'>
    <small>string</small>
    <font color='#cc0000'></font>
    <i>(length=0)</i>
    </pre>
    这段代码是用于处理post请求的,所以我直接用alert(data)显示出来了。以上
      

  5.   

    引用自手册: 
    mysql_query() 仅对 SELECT,SHOW,EXPLAIN 或 DESCRIBE 语句返回一个资源标识符,如果查询执行不正确则返回 FALSE。对于其它类型的 SQL 语句, mysql_query() 在执行成功时返回 TRUE,出错时返回 FALSE
    而你的代码我又没看出什么问题,我无解了
      

  6.   

    $result=$db->update($tid,$which,$where);
    var_dump($result);   单独执行php文件,贴出结果。
      

  7.   


    一样,显示null,数据库操作成功。<?phpinclude_once './check.php';$cid=77777778;
    $sid=94664;
    $tid=1001;
    $tid="`".$tid."`";
    $which="finish=1";
    $where="sid="."$sid"." and cid="."$cid";
    $db=new Mysql("localhost","root","","members_check","","UTF8");    
    $db->connect();
    $result=$db->update($tid,$which,$where);
    var_dump($result);
    ?>
      

  8.   

    public function update($table, $mod_content, $condition, $url = '') {
         $result=$this->query("UPDATE $table SET $mod_content WHERE $condition");
        var_dump($result);   
         return $result;
    }这里呢? 是什么结果? 
      

  9.   

    实在不行我用mysql_affected_rows()代替好了,mysql_affected_rows()返回是正常的
      

  10.   

    打印sql UPDATE $table SET $mod_content WHERE $condition
    看是不是没有条件没过来!
      

  11.   

    真是奇怪! 贴一下你的PHP版本,运行平台的信息吧
      

  12.   

    $result=$db->update($tid,$which,$where);
    var_dump($result);   
    显示 null显然LZ使用的代码与他贴出的代码是不一样的
    继续讨论是无意义的
      

  13.   


    仔细检查了下,找到问题了。./check.php里include的数据库类是我在编辑器里修改的数据库类的副本。我更改的都是最原先的那个数据库类。那里的query语句少了return。多谢楼上各位