我在我的php文件中遇到问题,错误来自第三个语句中的参数,但我找不到它在哪里。这是我的PHP文件:
$client = "test";
$resto = "test";
$st1 = mysqli_query($con, "SELECT client_id FROM Clients WHERE email = '$client'");
$res1 = mysqli_fetch_array($st1);
$clientID = $res1["client_id"];
echo "CLIENT ID = ";
echo $clientID;
$st2 = mysqli_query($con, "SELECT restaurant_id FROM Restaurants WHERE email = '$resto'");
$res2 = mysqli_fetch_array($st2);
$restaurantID = $res2["restaurant_id"];
echo "RESTO ID = ";
echo $restaurantID;
$statement = mysqli_prepare($con, "INSERT INTO reservations (resto_id, client_id) VALUES ($restaurantID,$clientID)");
mysqli_stmt_bind_param($statement,"ii",$restaurantID,$clientID);
mysqli_stmt_execute($statement);
$response = array();
$response["success"] = true;
echo json_encode($response);
提前感谢您的帮助。
答案 0 :(得分:0)
改变你的陈述,如下文
$statement = mysqli_prepare($con, "INSERT INTO reservations (resto_id, client_id) VALUES ( ? , ? )");