无法插入数据库mysql

我无法将它插入到我的数据库 mysql 中,但我认为我已经以正确的方式做到了。有谁知道如何解决它?或者我错过了什么?它实际上所有的工作。但它不会从我放入邮递员的身体中获取价值

http://img2.mukewang.com/6134949b00019aca13620945.jpg

  <?php

if (! isset($_POST['review'])) {

    responJson(['success' => false, 'messege' => "'review' harus diisi"]);

    exit;

}

if (! isset($_POST['rating'])) {

    responJson(['success' => false, 'messege' => "'rating' harus diisi"]);

    exit;

}

if (! isset($_POST['id_user'])) {

    responJson(['success' => false, 'messege' => "'id_user' harus diisi"]);

    exit;

}

if (! isset($_POST['id_movie'])) {

    responJson(['success' => false, 'messege' => "'id_movie' harus diisi"]);

    exit;

}


//bersihkan data

$review = mysqli_real_escape_string($connection, $_POST['review']);

$rating = mysqli_real_escape_string($connection, $_POST['rating']);

$user_id = mysqli_real_escape_string($connection, $_POST['id_user']);

$movie_id = mysqli_real_escape_string($connection, $_POST['id_movie']);


//masukkan data ke db

$query = mysqli_query($connection, 'INSERT INTO user_review (review, rating, id_user, id_movie)

values ("'. $review .'", "'. $rating .'", "'. $user_id .'", "'. $movie_id .'")');

//cek berhasil atau tidak dimasukkan db

if ($query) {

    responJson(['success' => true, 'messege' => 'sukses memasukkan data']);

} else {

    responJson(['success' => false, 'messege' =>  mysqli_error($connection)]);

}


牧羊人nacy
浏览 191回答 1
1回答

陪伴而非守候

单击 raw 并从下拉列表中选择 json(application/json) 并以 json 格式在正文中添加以下代码{&nbsp; "review": "bagus",&nbsp; "rating": "3",&nbsp; "id_user": "2",&nbsp; "id_movie": "3"}
打开App,查看更多内容
随时随地看视频慕课网APP