我没有发现任何错误.此代码很好.完美地更新了我的数据.但显示了1个错误 [英] I don't find any error.this code doing well.update my data perfectly.but 1 error is showing

查看:83
本文介绍了我没有发现任何错误.此代码很好.完美地更新了我的数据.但显示了1个错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

if ($_SERVER["REQUEST_METHOD"]=="POST") {
            $updatedate=$_POST['date'];
            $updateday=$_POST['day'];
            $updateplace=$_POST['place'];
            $updatehighlight=$_POST['highlight'];
            $updatediscription=$_POST['discription'];
            $sqlupdate="UPDATE $tableselect SET entrydate='$updatedate',day='$updateday',place='$updateplace',highlight='$updatehighlight',discription='$updatediscription' WHERE id ='$getid'";
            $sqlquery=mysqli_query($db,$sqlupdate);
            if (!mysqli_query($db,$sqlquery)) {
                    echo "error " .$sqlquery. "<br>" . mysqli_error($db);
                }
        }

它显示此错误:

您的SQL语法有错误;检查与您的MariaDB服务器版本相对应的手册以获取正确的语法,以在第1行的'1'附近使用

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1' at line 1

推荐答案

很简单,您要运行两次查询功能,这就是为什么要获取1的原因.

Real simple, you're running the query function twice, that's why you're getting 1.

所以

$sqlquery=mysqli_query($db,$sqlupdate);
            if (!mysqli_query($db,$sqlquery)) {...}

需要更改为公正

$sqlquery=mysqli_query($db,$sqlupdate);
            if(!$sqlquery){...}

第一个被执行,并且(if)!运算符也将触发查询函数,因为它为TRUE,如(if)not failing".

The first gets executed, and the (if)! operator will also trigger the query function since it was TRUE, as in "(if)not failing".

对于其他成功的查询,mysqli_query()将返回 TRUE ."

"For other successful queries mysqli_query() will return TRUE."

还对查询进行参数设置,您可以进行SQL注入.

Parametrize your query also, you're open to an SQL injection.

这篇关于我没有发现任何错误.此代码很好.完美地更新了我的数据.但显示了1个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆