Mysqli_stmt_prepare 失败

Mysqli_stmt_prepare failed

第一次尝试建立一个网站,除了这个特定的连接之外,所有其他连接都有效。我正在尝试连接到服务器并更新一个非特定变量。但是,当我检查 if(!mysqli_stmt_prepare($stmt, $sql))

时失败
function addWeight($conn, $location, $weight){
require_once "dbh.inc.php";
$sql ="UPDATE userWeight SET ?=? WHERE userId = ?;";
$stmt = mysqli_stmt_init($conn);
mysqli_stmt_prepare($stmt, $sql);
if (!mysqli_stmt_prepare($stmt, $sql)) {
    header("location: ../profile.php?error=sqlerror");
    exit();
}
mysqli_stmt_bind_param($stmt, "ssi",$location,$weight, $_SESSION["userid"]);
mysqli_stmt_execute($stmt);

//$result = mysqli_query($conn, $sql);
$result =mysqli_stmt_get_result($stmt);
    
$resultCheck = mysqli_num_rows($result);

// close statment 
mysqli_stmt_close($stmt);

}

调用函数的地方

<?php 
if(isset($_POST["submit"])){
    require_once "dbh.inc.php";
    require_once "functions.inc.php";
    
    session_start();
    
    $weight = $_POST['Weight'];
    // check if weight is full, if so shift all down and replace last 
    if($_SESSION['numWeight'] == 20){
        echo "WEIGHT IS FULL";
    }else{ // just add to next 
        $add = $_SESSION['numWeight']+1;
        $location ="Weight";
        $location .= strval($add);
    
        addWeight($conn, $location, $weight);
        
    }
}

addWeight 中似乎有两次调用 mysqli_stmt_prepare。也许尝试只调用一次?此外,mysqli_stmt_prepare documentation 表示不能使用问号“指定二元运算符的两个操作数,例如 = 等号。”