为了账号安全,请及时绑定邮箱和手机立即绑定

无法插入数据库mysql

无法插入数据库mysql

PHP
牧羊人nacy 2021-09-05 17:57:29
我无法将它插入到我的数据库 mysql 中,但我认为我已经以正确的方式做到了。有谁知道如何解决它?或者我错过了什么?它实际上所有的工作。但它不会从我放入邮递员的身体中获取价值  <?phpif (! 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 dbif ($query) {    responJson(['success' => true, 'messege' => 'sukses memasukkan data']);} else {    responJson(['success' => false, 'messege' =>  mysqli_error($connection)]);}
查看完整描述

1 回答

?
陪伴而非守候

TA贡献1757条经验 获得超8个赞

单击 raw 并从下拉列表中选择 json(application/json) 并以 json 格式在正文中添加以下代码


{

  "review": "bagus",

  "rating": "3",

  "id_user": "2",

  "id_movie": "3"

}


查看完整回答
反对 回复 2021-09-05
  • 1 回答
  • 0 关注
  • 190 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信