<bdo id='AkOL2'></bdo><ul id='AkOL2'></ul>

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

    1. <i id='AkOL2'><tr id='AkOL2'><dt id='AkOL2'><q id='AkOL2'><span id='AkOL2'><b id='AkOL2'><form id='AkOL2'><ins id='AkOL2'></ins><ul id='AkOL2'></ul><sub id='AkOL2'></sub></form><legend id='AkOL2'></legend><bdo id='AkOL2'><pre id='AkOL2'><center id='AkOL2'></center></pre></bdo></b><th id='AkOL2'></th></span></q></dt></tr></i><div id='AkOL2'><tfoot id='AkOL2'></tfoot><dl id='AkOL2'><fieldset id='AkOL2'></fieldset></dl></div>
      <tfoot id='AkOL2'></tfoot>

    2. <legend id='AkOL2'><style id='AkOL2'><dir id='AkOL2'><q id='AkOL2'></q></dir></style></legend>
    3. PDO 更新多条记录

      PDO Updating multiple records(PDO 更新多条记录)

      <legend id='cjIpx'><style id='cjIpx'><dir id='cjIpx'><q id='cjIpx'></q></dir></style></legend>

        • <bdo id='cjIpx'></bdo><ul id='cjIpx'></ul>
          <tfoot id='cjIpx'></tfoot>

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

          <i id='cjIpx'><tr id='cjIpx'><dt id='cjIpx'><q id='cjIpx'><span id='cjIpx'><b id='cjIpx'><form id='cjIpx'><ins id='cjIpx'></ins><ul id='cjIpx'></ul><sub id='cjIpx'></sub></form><legend id='cjIpx'></legend><bdo id='cjIpx'><pre id='cjIpx'><center id='cjIpx'></center></pre></bdo></b><th id='cjIpx'></th></span></q></dt></tr></i><div id='cjIpx'><tfoot id='cjIpx'></tfoot><dl id='cjIpx'><fieldset id='cjIpx'></fieldset></dl></div>

                  <tbody id='cjIpx'></tbody>
              1. 本文介绍了PDO 更新多条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我知道以前有人问过这个问题,我已经回答了很多问题,并且正在解决其中一个问题 现在回答,但是需要以下代码块的帮助.

                I know this question has been asked before and I've gone through many of the answers and am working off one of those answers now, however need some help with the following chunk of code.

                <?php
                
                $title = $_POST['title'];
                $description = $_POST['description'];
                $item_name = $_POST['item_name'];
                
                $A = count($item_name);
                
                include ("connection.php");
                
                try {
                
                    $set_details = "UPDATE images
                                    SET title = :title,
                                    description = :description,
                                    WHERE item_name = :item_name";
                
                
                $STH = $conn->prepare($set_details);
                
                    $i = 0;
                    while($i < $A) {
                        $STH->bindParam(':title', $title[$i]);
                        $STH->bindParam(':description', $description[$i]);
                        $STH->bindParam(':item_name', $item_name[$i]);
                        $STH->execute();
                        $i++;
                    }
                }
                catch(PDOException $e) {  
                    echo "I'm sorry, but there was an error updating the database.";  
                    file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
                }
                
                
                ?>
                

                我在执行时没有收到任何错误,也没有任何东西提交到 mysql 表,如果你发现了什么,请告诉我,或者如果有更好的方法来解决这个问题,你能指点我一个教程吗,我没有与 PDO 或多行更新一起工作很多.

                I get no errors upon execution and nothing is submitted to the mysql table, if you spot something please let me know, or if there is a better way to go about this could you point me towards a tutorial, I haven't worked much with PDO or multiple row updates yet.

                提前致谢.

                致山姆:

                print_r($STH->errorInfo());
                

                输出是:

                Array ( [0] => 42000 [1] => 1064 [2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE item_name = '27'' at line 4 )
                

                推荐答案

                :description后面多了一个逗号,应该是:

                You have an extra comma after :description, it should be:

                "UPDATE images
                 SET title = :title,
                 description = :description
                 WHERE item_name = :item_name"
                

                这篇关于PDO 更新多条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                • <bdo id='Jdi61'></bdo><ul id='Jdi61'></ul>
                    <i id='Jdi61'><tr id='Jdi61'><dt id='Jdi61'><q id='Jdi61'><span id='Jdi61'><b id='Jdi61'><form id='Jdi61'><ins id='Jdi61'></ins><ul id='Jdi61'></ul><sub id='Jdi61'></sub></form><legend id='Jdi61'></legend><bdo id='Jdi61'><pre id='Jdi61'><center id='Jdi61'></center></pre></bdo></b><th id='Jdi61'></th></span></q></dt></tr></i><div id='Jdi61'><tfoot id='Jdi61'></tfoot><dl id='Jdi61'><fieldset id='Jdi61'></fieldset></dl></div>
                          <tbody id='Jdi61'></tbody>

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

                          <tfoot id='Jdi61'></tfoot>
                        1. <legend id='Jdi61'><style id='Jdi61'><dir id='Jdi61'><q id='Jdi61'></q></dir></style></legend>