Php Mysqli Update语句未更新数据库无错误

Php Mysqli Update语句未更新数据库无错误,php,html,ajax,Php,Html,Ajax,我尝试了不同的方式/语句方法来让这个update语句工作,但我不知道发生了什么。。。数据库未更新,并且未出现任何错误。什么也没发生。真的有点不对劲 //editDetails if(isset($_POST['editDetails'])){ //bind parameters $updatecompany = $db->prepare("UPDATE company SET `title`=?, `description`=?, `address`=?, `type`=?, `coun

我尝试了不同的方式/语句方法来让这个update语句工作,但我不知道发生了什么。。。数据库未更新,并且未出现任何错误。什么也没发生。真的有点不对劲

//editDetails
if(isset($_POST['editDetails'])){

//bind parameters
$updatecompany = $db->prepare("UPDATE company SET `title`=?, `description`=?, `address`=?, `type`=?, `country`=?, `timezone`=? WHERE `id`=?");
$updatecompany->bind_param('ssssss',$_POST['title'],$_POST['type'],$_POST['description'],$_POST['address'],$_POST['country'],$_POST['timezone']);
$updatecompany->execute();

    // set parameters and execute
    $companyid = mysqli_real_escape_string($db, $_POST["id"]);
    $title = mysqli_real_escape_string($db, $_POST["title"]);
    $type = mysqli_real_escape_string($db, $_POST["type"]);
    $description = mysqli_real_escape_string($db, $_POST["description"]);
    $address = mysqli_real_escape_string($db, $_POST["address"]);
    $country = mysqli_real_escape_string($db, $_POST["country"]);
    $timezone = mysqli_real_escape_string($db, $_POST["timezone"]);

if($updatecompany){
 // echo "Data Submitted succesfully";
  header('Location: ' . $_SERVER['HTTP_REFERER']);
exit;
  }
$updatecompany->close();
$db->close();
}
编辑

form.php


谢谢大家的帮助。我用下面的代码实现了查询

//editDetails
if(isset($_POST['editDetails'])){

    // set parameters and execute
    $companyid = $_POST["companyid"];
    $title = $_POST["title"];
    $type = $_POST["type"];
    $description = $_POST["description"];
    $address = $_POST["address"];
    $country = $_POST["country"];
    $timezone = $_POST["timezone"];

    $updatecompany = "UPDATE company SET title = '$title', type='$type', description='$description', address='$address', country='$country', timezone='$timezone' WHERE id='$companyid'";
    mysqli_select_db($db, 'mydb');
    $resultq = mysqli_query($db, $updatecompany);

if(! $resultq ){
 die('Could not update data: ' . mysqli_error($db));
}
$db->close();
  header('Location: ' . $_SERVER['HTTP_REFERER']);
exit;
  }

您没有检查错误。数一数?ss,看起来你忘了绑定id。我也不清楚你在执行后做了什么,但是你的注释//设置参数和执行是错误的,执行已经发生了,不需要转义。如果你使用的是一个准备好的语句,为什么还要使用mysqli\u real\u escape\u字符串?这些帖子有值吗?添加一个else{echo Error:.mysqli_Error$db;}就可以编辑这个问题了。我退出了。我很少使用mysqli,我会偏离语法,在这里询问历史。如果你以前使用过它,那么它是失败的,请使用@Fred ii-post。占位符和绑定总是需要匹配。没有错误报告的开发是很难做到的。首先使用无效查询,以便确认错误报告正在工作。
 <form id="editDetails" method="POST" action="core/query.php">
<table>
<thead></thead>
 <tbody>
 <?php while($company=mysqli_fetch_array($result)){ ?>
  <tr>
      <td data-th="Name"><?=$company['title'];?></td>
    <td data-th="Description"><?=$company['description'];?></td>
    <td data-th="Type"><?=$company['type'];?></td>
    <td data-th="Address"><?=$company['address'];?></td>
    <td data-th="Country"><?=$company['country'];?></td>
    <td data-th="Time Zone"><?=$company['timezone'];?></td>
    <td data-th="ID" sorttable_customkey="2"><button id='editCompanyDetails'  class='btn btn-default btn-sm' type='button'  name='companyDetails' data-toggle="modal"data-target="#myModal2" title='Edit details'>
     <i class="fa fa-pencil-square-o" aria-hidden="true"></i></button></td>
<input name="companyid" type="hidden" type="hidden" class="formBlock btn btn-success"  value="<?=$company['id'];?>"/>
  </tr>
    <?php };?>
 </tbody>
<tfoot></tfoot>
</table>

<!-- Modal -->
<div id="myModal2" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
<div class="modal-header">
</div>
<div class="modal-body">
<input id='title' class='form-control formBlock' name='title' value='' type='text' placeholder="Name...">
 <select id='type' class='form-control formBlock' name='type'></select>
 <select id='type' class='form-control formBlock' name='description'></select>
 <input id='address' class='form-control formBlock' name='address' value='' type='text' placeholder="Address">
<select name="country"  id='country' class='form-control formBlock' name='country' value='' type='text' placeholder="Country"></select>
  <select id='timezone' class='form-control formBlock' name="timezone"></select>
<input name="editDetails" id="submit" type="submit" class="formBlock btn btn-success"  value="Modify Data"/>
</div>
</div>
</div>

</form>
//editDetails
if(isset($_POST['editDetails'])){

    // set parameters and execute
    $companyid = $_POST["companyid"];
    $title = $_POST["title"];
    $type = $_POST["type"];
    $description = $_POST["description"];
    $address = $_POST["address"];
    $country = $_POST["country"];
    $timezone = $_POST["timezone"];

    $updatecompany = "UPDATE company SET title = '$title', type='$type', description='$description', address='$address', country='$country', timezone='$timezone' WHERE id='$companyid'";
    mysqli_select_db($db, 'mydb');
    $resultq = mysqli_query($db, $updatecompany);

if(! $resultq ){
 die('Could not update data: ' . mysqli_error($db));
}
$db->close();
  header('Location: ' . $_SERVER['HTTP_REFERER']);
exit;
  }