更新查询不工作Mysqli

时间:2015-12-02 17:10:22

标签: php mysqli

这是我的更新查询和一些代码,id来自上一页的会话,现在我想更新数据库,但它不能正常工作

Var.PHP:

function store($data) {
  $data = trim($data);
  $data = stripslashes($data);
  $data = htmlspecialchars($data);
  return $data;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {

$CT_ID = store($_POST['CT_ID']); 
$Total_bales = store($_POST['Total_bales']);
$Country = store($_POST['Country']);

$Asian = store($_POST['Asian']); 
$BabyGrow = store($_POST['BabyGrow']); 
$Boys_Pants = store($_POST['Boys_Pants']);
$Boys_Colour_Shirts = store($_POST['Boys_Colour_Shirts']);
$Boys_White_Shirts = store($_POST['Boys_White_Shirts']);
$Bra = store($_POST['Bra']);
$CMR = store($_POST['CMR']);
$CR = store($_POST['CR']);
}

它们有大约62个输入字段和变量:(

这是bales.php页面

    sec_session_start();
$Current_CT_ID = $_SESSION['ct_id'];
 <body>
   <?php if (login_check($mysqli) == true) :

      $sql = "UPDATE container SET Asian = '$Asian', BabyGrow = '$BabyGrow' WHERE CT_ID = $Current_CT_ID";

      if ($mysqli->query($sql) === TRUE) {
          echo "Record updated successfully";
      } else {
          //echo "<p> Error updating record:" . $mysqli->error; "</p>";
          //MySqli Update Query

           print 'Error : ('. $mysqli->errno .') '. $mysqli->error;
      } 
    ?>

<h3>Current Id: <?php echo $Current_CT_ID; ?></h3>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post" name="bales_form" class="form" role="form">
      <div class="form-group">      
         <div class="col-lg-3 col-xs-12 bg-info">
          <div class="squaredOne pull-left">
           <input type="checkbox" value="" id="Asian" name="check" />
           <label for="Asian"></label>
           </div>
           <span class="pull-left">Asian</span><span class="clearfix"></span>
           <input class="bg-alert" type="number" id="bales" name="Asian" min="0" placeholder="Asian Bales">
         </div>

         <div class="col-lg-3 col-xs-12 bg-info">
          <div class="squaredOne pull-left">
           <input type="checkbox" value="" id="BabyGrow" name="check" />
           <label for="BabyGrow"></label>
           </div>
           <span class="pull-left">Baby Grow</span><span class="clearfix"></span>
           <input class="bg-alert" type="number" id="bales" name="BabyGrow" min="0" placeholder="Baby Grow Bales">
         </div>

 <button style="height:45px; font-weight:bold;" class="btn-block btn btn-lg btn-info">Submit</button>

     </form> 

现在错误是

  

警告:trim()期望参数1为字符串,数组为   第3行/home3/bobscas1/public_html/baling-system/includes/var.php

此外,它说唱片更新成功,但db表未更新,实际上没有记录。

var_dump($ _ POST);结果是这个

array(24) { ["Asian"]=> string(1) "4" ["BabyGrow"]=> string(1) "5" ["Boys_Pants"]=>

先谢谢

1 个答案:

答案 0 :(得分:0)

array(24) { ["Asian"]=> string(2) "13" ["BabyGrow"]=> string(2) "34" ["Boys_Pants"]=> string(0) "" ["Boys_Colour_Shirts"]=> string(0) "" ["Boys_White_Shirts"]=> string(0) "" ["Bra"]=> string(0) "" ["CMR"]=> string(0) "" ["CR"]=> string(0) "" ["Children_Jogger"]=> string(0) "" ["Children_Polo"]=> string(0) "" ["Cordory_Pants"]=> string(0) "" ["Children_TShirts"]=> string(0) "" ["Girls_Top"]=> string(0) "" ["Girdle"]=> string(0) "" ["HHR_Curtain"]=> string(0) "" ["Infant_Pants"]=> array(1) { [15]=> string(0) "" } ["Jeans_Pant_Men"]=> string(0) "" ["Jeans_Short"]=> string(0) "" ["Jeans_Skirt"]=> array(1) { [18]=> string(0) "" } ["Jeans_Shirt"]=> string(0) "" ["Joggers"]=> string(0) "" ["LHHR"]=> string(0) "" ["Cotton_Blouse"]=> string(0) "" ["Cotton_Dress"]=> string(0) "" }