当前位置: 首页 > 知识库问答 >
问题:

对应于正确语法的MariaDB服务器版本的手册中的错误

秦权
2023-03-14

我不知道为什么会出现错误,我只是添加了一个新列。

<?php

    $Title    = $_POST['title'];
    $First    = $_POST['first'];
    $Middle   = $_POST['middle'];
    $Last     = $_POST['last'];
    $Address1 = $_POST['address1'];
    $Address2 = $_POST['address2'];
    $Address3 = $_POST['address3'];
    $City     = $_POST['city'];
    $State    = $_POST['state'];
    $Postal   = $_POST['postal'];
    $Province = $_POST['province'];
    $Gender   = $_POST['gender'];
    $Phone    = $_POST['phone'];
    $DialCode = $_POST['dial'];
    $Altphone = $_POST['altphone'];
    $Service  = $_POST['service'];
    $Email    = $_POST['email'];
    $Comment  = $_POST['comment'];

    $host ="localhost";
    $dbusername = "root";
    $dbpassword = "";
    $dbname = "vici";

    $conn = new mysqli($host,$dbusername,$dbpassword,$dbname);


    if (mysqli_connect_error())
    {
        echo "Failed to connect to MySQL:".mysqli_connect_error();
    }
    else{
        $fet = "SELECT * FROM userdetail ORDER BY Vendor DESC LIMIT 1";
        {
            if ($conn->query($fet))
            {
                $upd = " UPDATE userdetail SET Tittle = '$Title', First = '$First', Middle = '$Middle', Last = '$Last', Address1 = '$Address1', Address2 = '$Address2', Address3 = '$Address3', City = '$City', State = '$State', Postal = '$Postal', Province = '$Province', Gender = '$Gender', Phone = '$Phone', DialCode = '$DialCode', Altphone = '$Altphone', Service = '$Service', Email = '$Email', Comment = '$Comment' 
                WHERE SN = $fet ";

                if ($conn->query($upd))
                {
                    echo "Record will update";
                    echo "<script> window.location.assign('Userdataretrive.php'); </script>";
                }
                else {
                    {
                        echo "Updating Error !!! " .$conn->error; 
                    }
                }
            }
            $conn->close();
        }
    }  
?>

更新错误!!!您的SQL语法有错误;检查与您的MariaDB服务器版本相对应的手册,以了解第2行“从用户详细信息订单按供应商描述限制1选择*”附近使用的正确语法

共有1个答案

凤昊东
2023-03-14

子查询需要在其周围使用paren。

WHERE SN = $fet ";

可以改成

WHERE SN = ( $fet )";
 类似资料: