【问题标题】:Check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE id ='2'' at line 4检查与您的 MariaDB 服务器版本相对应的手册,以了解在第 4 行的“WHERE id ='2”附近使用的正确语法
【发布时间】:2018-03-22 04:09:01
【问题描述】:

我的更新代码有问题。它给了我这个错误:

更新失败!!您的 SQL 语法有错误;检查与您的 MariaDB 服务器版本相对应的手册,以在第 4 行的“WHERE id ='2'' 附近使用正确的语法

我正在网上搜索,但找不到任何解决问题的方法。
这是我的更新代码:

<?php

    include('db.php');
    $id = $_GET['id'];
    if (isset($_POST['id'])){

    $sql = "UPDATE tbl_student SET stud_id ='".$_POST['stud_id']."',
                                    fullname ='".$_POST['fullname']."',
                                    course ='".$_POST['course']."',
                                    WHERE id ='".$_POST['id']."'";

    $result = $conn->query($sql) or die ("Update Failed!!" . $conn->error);

    header("location: index.php");
    }

    else {
        echo "ERROR" . $conn->error;
        header ("location: update.php");
    }

?>

【问题讨论】:

  • 你听说过sql注入攻击吗?

标签: php


【解决方案1】:

你在课程结束后终于添加了,。去掉它。将您的查询更改为:

$sql = "UPDATE tbl_student SET stud_id ='".$_POST['stud_id']."',
                                    fullname ='".$_POST['fullname']."',
                                    course ='".$_POST['course']."'
                                    WHERE id ='".$_POST['id']."'";

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-27
    • 2018-08-28
    • 1970-01-01
    • 2019-05-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多