SQL语法错误,请我检查Maria Db服务器文档

时间:2019-06-28 08:40:12

标签: php mysqli

我已经尝试了很多方法,但是仍然无法解决。

此错误有解决方案吗?

  

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

if (isset($_GET['assign_dept'])) 
{
    $member_id = $_GET['assign_dept'];

    $query = "SELECT * FROM member WHERE member_id = '$member_id'";
    $result = mysqli_query($connection, $query);

    while ($row=mysqli_fetch_array($result)) 
    {
        $member_id = $row['member_id'];
        $name =$row['name'];
        $department_name = $row['department_name'];     
        $admin_id = $_SESSION['admin_id'];
    }

    if (isset($_POST['update_btn']))
    {
        $department_name = $_POST['department_name'];

        $queryUpdate = "UPDATE member SET department_name = '$department_name' WHERE  member_id = '".$_GET['assign_dept']."'";
        $sql = mysqli_query($connection, $queryUpdate);
        if ($sql) 
        {
            echo '<script language="javascript">';
            echo "alert('Department Determination Has Been Succesfull'); window.location.href='dashboardOrganizationMember.php'"; 
            echo '</script>';
        }
        else 
        {
            // echo '<script language="javascript">';
            // echo 'alert("Department Determination Has Fail")';
            // echo '</script>';
            echo mysqli_error($connection);

        }
    }
}

我希望可以在数据库内部更新数据。

0 个答案:

没有答案