久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <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="qwawimqqmiuu" 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="qwawimqqmiuu" 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="qwawimqqmiuu" 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>
                            主站蜘蛛池模板: 国产精品自产av一区二区三区 | 一级黄色毛片a | 欧美一级淫片免费视频黄 | 免费观看毛片 | 婷婷色国产偷v国产偷v小说 | 在线国产视频 | 福利视频二区 | 在线视频 中文字幕 | 久久久久久成人网 | 亚洲美女在线视频 | 亚洲iv一区二区三区 | 国产精品国产三级国产aⅴ原创 | 久久久噜噜噜www成人网 | 成人精品在线视频 | www.中文字幕.com| 欧美日韩一二三区 | 日韩第一页 | 亚洲乱码一区二区 | 成年免费大片黄在线观看一级 | 日韩欧美视频 | 成人福利在线视频 | 精品久久久久久久 | 美女黄网站 | 国产精品揄拍一区二区久久国内亚洲精 | 日本超碰 | 亚洲精品在线观看视频 | 欧美激情欧美激情在线五月 | 97久久久久久久久 | 亚洲成色777777在线观看影院 | se婷婷 | 91原创视频在线观看 | 99久久精品国产一区二区三区 | 亚洲国产视频一区二区 | 欧美一区二区在线播放 | 国产一区 在线视频 | 久久精品综合网 | 一级黄片一级毛片 | www.一区二区三区 | 雨宫琴音一区二区在线 | 亚洲精品第一 | 国产偷录叫床高潮录音 |