在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;
}
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;
}
我用if($result){echo 0;}else{echo 1;}的话,不返回0
在代码后面加上一句 var_dump($result, mysql_error()); 贴出结果
<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)显示出来了。以上
mysql_query() 仅对 SELECT,SHOW,EXPLAIN 或 DESCRIBE 语句返回一个资源标识符,如果查询执行不正确则返回 FALSE。对于其它类型的 SQL 语句, mysql_query() 在执行成功时返回 TRUE,出错时返回 FALSE
而你的代码我又没看出什么问题,我无解了
var_dump($result); 单独执行php文件,贴出结果。
一样,显示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);
?>
$result=$this->query("UPDATE $table SET $mod_content WHERE $condition");
var_dump($result);
return $result;
}这里呢? 是什么结果?
看是不是没有条件没过来!
var_dump($result);
显示 null显然LZ使用的代码与他贴出的代码是不一样的
继续讨论是无意义的
仔细检查了下,找到问题了。./check.php里include的数据库类是我在编辑器里修改的数据库类的副本。我更改的都是最原先的那个数据库类。那里的query语句少了return。多谢楼上各位