• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

MySQL操作实施成功,但没有返回值

php 搞代码 3年前 (2022-01-24) 16次浏览 已收录 0个评论

MySQL操作执行成功,但没有返回值?
在MySQL console中执行:

SQL code

<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->mysql>update `1001` set finish=0 where sid=94664;Query OK,1 row affected (0.07 sec)Rows matched:1 changed:1 warnings:0

php中的语本文来源gao.dai.ma.com搞@代*码#网搞代gaodaima码句:

PHP code

<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$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。但是数据库里全部操作成功。

附上封装的函数:

PHP code

<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->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;}

——解决方案——————–
$result=$db->update($tid,$which,$where);
var_dump($result);
显示 null

显然LZ使用的代码与他贴出的代码是不一样的
继续讨论是无意义的


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:MySQL操作实施成功,但没有返回值
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址