Php 数据库表未更新

Php 数据库表未更新,php,mysql,Php,Mysql,嗨,我正在尝试更新我的tbl_jadwal,它说成功了,但数据库没有更新,任何人都可以帮我找到问题所在吗?谢谢 <?php if (isset($_GET['id'])) { $ID = $_GET['id']; } else { $ID = ""; } // create array variable to store category data $category_data = array(); $

嗨,我正在尝试更新我的tbl_jadwal,它说成功了,但数据库没有更新,任何人都可以帮我找到问题所在吗?谢谢

 <?php

    if (isset($_GET['id'])) {
        $ID = $_GET['id'];
    } else {
        $ID = "";
    }

    // create array variable to store category data
    $category_data = array();

    $sql_query = "SELECT Category_ID, Category_name 
            FROM tbl_category 
            ORDER BY Category_ID ASC";

    $stmt_category = $connect->stmt_init();
    if ($stmt_category->prepare($sql_query)) {
        // Execute query
        $stmt_category->execute();
        // store result 
        $stmt_category->store_result();
        $stmt_category->bind_result($category_data['Category_ID'],
            $category_data['Category_name']
        );

    }

    $sql_query = "SELECT Menu_image FROM tbl_jadwal WHERE Menu_ID = ?";

    $stmt = $connect->stmt_init();
    if ($stmt->prepare($sql_query)) {
        // Bind your variables to replace the ?s
        $stmt->bind_param('s', $ID);
        // Execute query
        $stmt->execute();
        // store result
        $stmt->store_result();
        $stmt->bind_result($previous_menu_image);
        $stmt->fetch();
        $stmt->close();
    }


    $stmt = $connect->stmt_init();
    if ($stmt->prepare($sql_query)) {
        // Execute query
        $stmt->execute();
        // store result
        $stmt->store_result();
        $stmt->fetch();
        $stmt->close();
    }


    if (isset($_POST['btnEdit'])) {

        $nama_lokasi = $_POST['nama_lokasi'];
        $category_ID = $_POST['category_ID'];
        $longitude = $_POST['longitude'];
        $latitude = $_POST['latitude'];
        $phone = $_POST['phone'];
        $email = $_POST['email'];
        $description = $_POST['description'];


        // get image info
        $menu_image = $_FILES['menu_image']['name'];
        $image_error = $_FILES['menu_image']['error'];
        $image_type = $_FILES['menu_image']['type'];

        // create array variable to handle error
        $error = array();




  // updating all data              


$sql_query = "UPDATE tbl_jadwal 
                        SET Nama_Lokasi = ? , Category_ID = ?, Latitude = ?, Longitude = ?, Phone = ?, Email = ?, Menu_image = ?, Description = ? 
                        WHERE Menu_ID = ?";

                $upload_image = 'upload/images/' . $menu_image;
                $stmt = $connect->stmt_init();
                if ($stmt->prepare($sql_query)) {
                    // Bind your variables to replace the ?s
                    $stmt->bind_param('ssssssss',
                        $nama_lokasi,
                        $category_ID,
                        $longitude,
                        $latitude,
                        $phone,
                        $email,
                        $upload_image,
                        $description,
                        $ID);
                    // Execute query
                    $stmt->execute();
                    // store result 
                    $update_result = $stmt->store_result();
                    $stmt->close();
                }
            } else {
检查更新结果

  if ($update_result) {
                $error['update_data'] = " <span class='label label-primary'>Success update</span>";
            } else {
                $error['update_data'] = " <span class='label label-danger'>failed update</span>";
            }
if($update\u结果){
$error['update_data']=“成功更新”;
}否则{
$error['update_data']=“更新失败”;
}
这是我的数据库结构


首先编写简单的查询,然后添加解释。 例如:

解释更新表set name='test',其中id=1

此语句将显示所有可能的错误。通过这种方式,您将能够解决问题。

bind_param()
替换为
bindParam(':data',$data)


或者尝试
$stmt->execute(array(':data'=>$data))

你能粘贴sql表结构吗?嗨,Andrei Todorut,谢谢你的帮助,我已经把我的数据库截图放好了。谢谢你,我已经找到了解决方案,我在bind_paramhi中错过了一个“s”;,谢谢你,我已经找到了解决方案,我想念一个人的bind_paramhi谢谢我已经找到了解决方案,我想念一个人的bind_param
  if ($update_result) {
                $error['update_data'] = " <span class='label label-primary'>Success update</span>";
            } else {
                $error['update_data'] = " <span class='label label-danger'>failed update</span>";
            }