pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <small id='bkc4D'></small><noframes id='bkc4D'>

    <tfoot id='bkc4D'></tfoot>
      <bdo id='bkc4D'></bdo><ul id='bkc4D'></ul>

      1. <legend id='bkc4D'><style id='bkc4D'><dir id='bkc4D'><q id='bkc4D'></q></dir></style></legend>
        <i id='bkc4D'><tr id='bkc4D'><dt id='bkc4D'><q id='bkc4D'><span id='bkc4D'><b id='bkc4D'><form id='bkc4D'><ins id='bkc4D'></ins><ul id='bkc4D'></ul><sub id='bkc4D'></sub></form><legend id='bkc4D'></legend><bdo id='bkc4D'><pre id='bkc4D'><center id='bkc4D'></center></pre></bdo></b><th id='bkc4D'></th></span></q></dt></tr></i><div class="slhodio" id='bkc4D'><tfoot id='bkc4D'></tfoot><dl id='bkc4D'><fieldset id='bkc4D'></fieldset></dl></div>

        為什么此 SQL UPDATE 查詢不適用于 WHERE 的變量?

        Why does this SQL UPDATE query not work with a variable for WHERE?(為什么此 SQL UPDATE 查詢不適用于 WHERE 的變量?)

          1. <legend id='JDK29'><style id='JDK29'><dir id='JDK29'><q id='JDK29'></q></dir></style></legend>
                <bdo id='JDK29'></bdo><ul id='JDK29'></ul>
              • <tfoot id='JDK29'></tfoot>
                1. <small id='JDK29'></small><noframes id='JDK29'>

                  <i id='JDK29'><tr id='JDK29'><dt id='JDK29'><q id='JDK29'><span id='JDK29'><b id='JDK29'><form id='JDK29'><ins id='JDK29'></ins><ul id='JDK29'></ul><sub id='JDK29'></sub></form><legend id='JDK29'></legend><bdo id='JDK29'><pre id='JDK29'><center id='JDK29'></center></pre></bdo></b><th id='JDK29'></th></span></q></dt></tr></i><div class="mu5j5ev" id='JDK29'><tfoot id='JDK29'></tfoot><dl id='JDK29'><fieldset id='JDK29'></fieldset></dl></div>
                    <tbody id='JDK29'></tbody>
                  本文介紹了為什么此 SQL UPDATE 查詢不適用于 WHERE 的變量?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  這是我在 Stack Overflow 上的第一篇文章.我知道這個問題之前已經被問過很多次了.我經歷了很多答案,嘗試了所有答案(顯然正確的方法除外),但不知道該嘗試什么了.

                  this is my first post here at Stack Overflow. I know the question has been asked many times before. I went through many answers, tried all of them (except the correct approach obviously) and don't know what to try anymore.

                  我有一個 SQL 表,其中每一行都有一個編輯"按鈕.單擊它時,我將所選行的 id 傳遞給 edit.php.在那里,我得到它并根據用戶從表單輸入的 id 更新給定的行.第一列是 id,設置為 AUTO_INCREMENT.

                  I have an SQL table where every row has an "edit" button. When clicking it, I pass over the id of the selected row to edit.php. There, I get it and update the given row based on the id with the user input from the form. The first column is id which is set to AUTO_INCREMENT.

                  順便說一句,無論我使用 WHERE id=$id"; 還是 WHERE id='$id'";

                  On a side note, I get the same error, no matter if I use WHERE id=$id"; or WHERE id='$id'";

                  我認為最接近正確方法的代碼如下,并在代碼下方生成錯誤消息:

                  The code which I think is closest to the correct approach is as follows and generates the error message below the code:

                  <html>
                      <title>
                          Video Archiv - New
                      </title>
                      
                      <body>
                          <?php
                              include("connect.php"); 
                              $id=$_GET['id'];
                              echo "Details von Video #$id editieren:<br /><br />";
                              
                              if(isset($_POST['update']))
                              {
                                  $sql =  "UPDATE VideoArchiv             
                                          SET ('".$_POST["titel"]."','".$_POST["schauspieler"]."')
                                          WHERE id=$id";
                  
                                          $result = mysqli_query($connect,$sql);
                  
                                  if (mysqli_query($connect,$sql) === TRUE) 
                                  {
                                      echo "Record updated successfully";
                                  } 
                                  else 
                                  {
                                      echo "Error updating record: " . $connect->error;
                                  }
                              }
                              ?>
                  
                          <form action="edit.php" method="post"> 
                              
                              <label> Titel:</label><br/>
                              <input type="text" name="titel" required><br/>
                  
                              <label>Schauspieler</label><br/>
                              <input type="text" name="schauspieler" required><br/>
                              <br />
                              <button type="submit" name="update">Speichern</button>
                                  
                          </form>
                  
                          <?php
                              include("back.php");
                          ?>
                      </body>
                  </html> 
                  

                  錯誤信息:

                  錯誤更新記錄:您的 SQL 語法有錯誤;檢查與您的 MySQL 服務器版本相對應的手冊,了解在第 2 行的 '('a','d') WHERE id=9' 附近使用的正確語法

                  非常感謝您的幫助,對于重復的問題很抱歉,但我真的找不到解決方案并且非常絕望.

                  Thanks a lot for your help and sorry for the duplicate question, but I really can't find the solution and am pretty desperate.

                  以下代碼給出了這個錯誤:

                  The following code gives this error:

                  致命錯誤:未捕獲的錯誤:在/homepages/25/d72758610/htdocs/multimedia/edit.php:30 中的 bool 上調用成員函數 bind_param() 堆棧跟蹤:#0 {main} throw in/homepages/25/d72758610/htdocs/multimedia/edit.php 第 30 行

                  Fatal error: Uncaught Error: Call to a member function bind_param() on bool in /homepages/25/d72758610/htdocs/multimedia/edit.php:30 Stack trace: #0 {main} thrown in /homepages/25/d72758610/htdocs/multimedia/edit.php on line 30

                  <html>
                      <title>
                          Video Archiv - New
                      </title>
                      
                      <body>
                          <?php
                              include("connect.php"); 
                              $id=$_GET['id'];
                              $title = $_POST["titel"];
                              $schauspieler = $_POST["schauspieler"];
                  
                              if(empty($title))
                              {
                                  echo "error";
                              }
                              elseif(empty($schauspieler))
                              {
                                  echo "error";
                              }
                              else
                              {
                                  $sql = "UPDATE users SET title=?, schauspieler=? WHERE id=?";
                                  $stmt= $connect->prepare($sql);
                                  $stmt->bind_param("ssi", $title, $schauspieler, $id);
                                  if($stmt->execute())
                                  {
                                        echo "Succes";
                                  }
                                  else
                                  {
                                    echo "something went wromg";
                                  }
                              }
                              ?>
                  
                          <form action="edit.php" method="post"> 
                              
                              <label> Titel:</label><br/>
                              <input type="text" name="titel" required><br/>
                  
                              <label>Schauspieler</label><br/>
                              <input type="text" name="schauspieler" required><br/>
                              <br />
                              <button type="submit" name="update">Speichern</button>
                                  
                          </form>
                  
                          <?php
                              include("back.php");
                          ?>
                      </body>
                  </html> 
                  

                  推薦答案

                  非常簡單,可以避免 sql 注入并使用最新代碼,并且您的 SQL 語法有錯誤.

                  Very simple to avoid sql injections and use up to date codes and You have an error in your SQL syntax.

                  這是一個例子:

                     include("connect.php"); 
                      $id=$_GET['id'];
                      $title = $_POST["titel"];
                      $schauspieler = $_POST["schauspieler"];
                  
                      if(empty($title)){
                      echo "error";
                      }elseif(empty($schauspieler)){
                      echo "error";
                      }else{
                  
                      $sql = "UPDATE VideoArchiv SET title=?, schauspieler=? WHERE id=?";
                      $stmt= $connect->prepare($sql);
                      $stmt->bind_param("ssi", $title, $schauspieler, $id);
                      if($stmt->execute()){
                        echo "Succes";
                      }else{
                        echo "something went wromg";
                      }
                  
                      }
                  

                  查看更多:https://phpdelusions.net/mysqli_examples/update

                  更新:第一個代碼對你有用,但如果你仍然想使用程序化的方式,那么我們這個:

                  UPDATE : First code will work for you, but if you still want to use procedural way then us this :

                  include("connect.php");
                  if ($_SERVER["REQUEST_METHOD"] == "POST") {
                  
                  //Check if we get id 
                  $Testid = $_GET['id'];
                  if(empty($Testid)){
                      echo "id is empty";
                  }else{
                      $id = $_GET['id'];
                  }
                  
                  
                  $title = $_POST["titel"];
                  $schauspieler = $_POST["schauspieler"];
                  
                      if(empty($title )){
                          echo "error". $title; 
                      }elseif(empty($schauspieler)){
                          echo "error". $schauspieler;
                      }else{
                         $sql = "UPDATE VideoArchiv SET title=?, schauspieler=? WHERE id=?";
                         $stmt = mysqli_prepare($connect, $sql);
                         mysqli_stmt_bind_param($stmt, 'ssi', $title, $schauspieler, $id);
                         mysqli_stmt_execute($stmt); 
                      }
                  }
                  

                  <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
                  
                  	<label> Titel:</label><br/>
                  	<input type="text" name="titel" required><br/>
                  
                  	<label>Schauspieler</label><br/>
                  	<input type="text" name="schauspieler" required><br/>
                  	<br />
                  	<button type="submit" name="update">Speichern</button>
                  
                  </form>

                  這篇關于為什么此 SQL UPDATE 查詢不適用于 WHERE 的變量?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  store_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
                  Call to undefined function mysqli_result::num_rows()(調用未定義的函數 mysqli_result::num_rows())
                  PHP Prepared Statement Problems(PHP 準備好的語句問題)
                  mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一個結果)
                  PHP MySQLi Multiple Inserts(PHP MySQLi 多次插入)
                  How do I make sure that values from MySQL keep their type in PHP?(如何確保 MySQL 中的值在 PHP 中保持其類型?)
                  <tfoot id='OuhIc'></tfoot>
                    • <bdo id='OuhIc'></bdo><ul id='OuhIc'></ul>
                        <i id='OuhIc'><tr id='OuhIc'><dt id='OuhIc'><q id='OuhIc'><span id='OuhIc'><b id='OuhIc'><form id='OuhIc'><ins id='OuhIc'></ins><ul id='OuhIc'></ul><sub id='OuhIc'></sub></form><legend id='OuhIc'></legend><bdo id='OuhIc'><pre id='OuhIc'><center id='OuhIc'></center></pre></bdo></b><th id='OuhIc'></th></span></q></dt></tr></i><div class="nrcuyw5" id='OuhIc'><tfoot id='OuhIc'></tfoot><dl id='OuhIc'><fieldset id='OuhIc'></fieldset></dl></div>

                            <tbody id='OuhIc'></tbody>

                            <small id='OuhIc'></small><noframes id='OuhIc'>

                          1. <legend id='OuhIc'><style id='OuhIc'><dir id='OuhIc'><q id='OuhIc'></q></dir></style></legend>
                            主站蜘蛛池模板: 上海防爆真空干燥箱-上海防爆冷库-上海防爆冷柜?-上海浦下防爆设备厂家? | 丁基胶边来料加工,医用活塞边角料加工,异戊二烯橡胶边来料加工-河北盛唐橡胶制品有限公司 | 冲锋衣滑雪服厂家-冲锋衣定制工厂-滑雪服加工厂-广东睿牛户外(S-GERT) | 废水处理-废气处理-工业废水处理-工业废气处理工程-深圳丰绿环保废气处理公司 | ★店家乐|服装销售管理软件|服装店收银系统|内衣店鞋店进销存软件|连锁店管理软件|收银软件手机版|会员管理系统-手机版,云版,App | 杭州|上海贴标机-百科| 一氧化氮泄露报警器,二甲苯浓度超标报警器-郑州汇瑞埔电子技术有限公司 | 浙江建筑资质代办_二级房建_市政_电力_安许_劳务资质办理公司 | 金刚网,金刚网窗纱,不锈钢网,金刚网厂家- 河北萨邦丝网制品有限公司 | 儿童乐园|游乐场|淘气堡招商加盟|室内儿童游乐园配套设备|生产厂家|开心哈乐儿童乐园 | 【黄页88网】-B2B电子商务平台,b2b平台免费发布信息网 | 注塑_注塑加工_注塑模具_塑胶模具_注塑加工厂家_深圳环科 | 维泰克Veertek-锂电池微短路检测_锂电池腐蚀检测_锂电池漏液检测 | 飞行者联盟-飞机模拟机_无人机_低空经济_航空技术交流平台 | 佛山商标注册_商标注册代理|专利注册申请_商标注册公司_鸿邦知识产权 | 齿式联轴器-弹性联轴器-联轴器厂家-江苏诺兴传动联轴器制造有限公司 | 塑料瓶罐_食品塑料瓶_保健品塑料瓶_调味品塑料瓶–东莞市富慷塑料制品有限公司 | 天津力值检测-天津管道检测-天津天诚工程检测技术有限公司 | 尚为传动-专业高精密蜗轮蜗杆,双导程蜗轮蜗杆,蜗轮蜗杆减速机,蜗杆减速机生产厂家 | 成都茶楼装修公司 - 会所设计/KTV装修 - 成都朗煜装饰公司 | 高温热泵烘干机,高温烘干热泵,热水设备机组_正旭热泵 | 液压升降货梯_导轨式升降货梯厂家_升降货梯厂家-河南东圣升降设备有限公司 | 胃口福饺子加盟官网_新鲜现包饺子云吞加盟 - 【胃口福唯一官网】 | 集装箱展厅-住人集装箱住宿|建筑|房屋|集装箱售楼处-山东锐嘉科技工程有限公司 | 安徽泰科检测科技有限公司【官方网站】| CCE素质教育博览会 | CCE素博会 | 教育展 | 美育展 | 科教展 | 素质教育展 | 众品地板网-地板品牌招商_地板装修设计_地板门户的首选网络媒体。 | 不锈钢电动球阀_气动高压闸阀_旋塞疏水调节阀_全立阀门-来自温州工业阀门巨头企业 | 陕西高职单招-陕西高职分类考试网| 无锡网站建设-做网站-建网站-网页设计制作-阿凡达建站公司 | 新疆系统集成_新疆系统集成公司_系统集成项目-新疆利成科技 | TwistDx恒温扩增-RAA等温-Jackson抗体-默瑞(上海)生物科技有限公司 | 合肥废气治理设备_安徽除尘设备_工业废气处理设备厂家-盈凯环保 合肥防火门窗/隔断_合肥防火卷帘门厂家_安徽耐火窗_良万消防设备有限公司 | 湿地保护| 膏方加工_丸剂贴牌_膏滋代加工_湖北康瑞生物科技有限公司 | 广域铭岛Geega(际嘉)工业互联网平台-以数字科技引领行业跃迁 | 阜阳成人高考_阜阳成考报名时间_安徽省成人高考网 | 专业广州网站建设,微信小程序开发,一物一码和NFC应用开发、物联网、外贸商城、定制系统和APP开发【致茂网络】 | 电子书导航网_电子书之家_电子书大全_最新电子书分享发布平台 | 电池高低温试验箱-气态冲击箱-双层电池防爆箱|简户百科 | 铝单板_铝窗花_铝单板厂家_氟碳包柱铝单板批发价格-佛山科阳金属 |