I find no error. This code works well. Refresh my details fine. But 1 error shows

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);
                }
        }

      

it shows this error:

You have an error in your SQL syntax; check the manual corresponding to the MariaDB server version for the correct syntax to use next to "1" on line 1

+3


source to share


1 answer


In fact, you are executing the request function twice, which is why you get 1

.

So,

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

      

only needs to be changed to

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

      



The first one is executed, and the (if) statement !

also runs the query function, since it evaluates to TRUE, as in the case "(if) does not work".

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

Parameterize your query as well, you are open to SQL injection.

+5


source







All Articles