【解決方法】フラッターPHPでエラーが発生しました


Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'user

.

FormatException: Unexpected character (at character 1)

ここに私のコードPHPがあります:

include "../connection.php";

$id_user = $_POST['id_user'];
$type    = $_POST['type'];

$sql = "SELECT id_history, date, total FROM history
        WHERE
        id_ user='$id_user' AND type='$type'
        ORDER BY date DESC
        ";

$result = $connect->query($sql);

if ($result->num_rows > 0) {
    $data = array();
    while ($row = $result->fetch_assoc()) {
        $data[] = $row;
    }
    echo json_encode(array(
        "success" => true,
        "data" => $data
    ));
} else {
    echo json_encode(array(
        "success" => false
    ));
}

私が試したこと:

混乱したので、まだ何もしていません

解決策 1

テキストを見てください、間にスペースがあります id_user..

コメント

タイトルとURLをコピーしました