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

      2. <tfoot id='EqzPv'></tfoot>

        <legend id='EqzPv'><style id='EqzPv'><dir id='EqzPv'><q id='EqzPv'></q></dir></style></legend>
      3. 具有多列的 PHP MySQL 更新集查询

        PHP MySQL Update Set query with Multiple columns(具有多列的 PHP MySQL 更新集查询)
          <bdo id='vBIZq'></bdo><ul id='vBIZq'></ul>

          <tfoot id='vBIZq'></tfoot>

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

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

                <i id='vBIZq'><tr id='vBIZq'><dt id='vBIZq'><q id='vBIZq'><span id='vBIZq'><b id='vBIZq'><form id='vBIZq'><ins id='vBIZq'></ins><ul id='vBIZq'></ul><sub id='vBIZq'></sub></form><legend id='vBIZq'></legend><bdo id='vBIZq'><pre id='vBIZq'><center id='vBIZq'></center></pre></bdo></b><th id='vBIZq'></th></span></q></dt></tr></i><div id='vBIZq'><tfoot id='vBIZq'></tfoot><dl id='vBIZq'><fieldset id='vBIZq'></fieldset></dl></div>
                    <tbody id='vBIZq'></tbody>
                • 本文介绍了具有多列的 PHP MySQL 更新集查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我已经用逗号和AND"语句尝试了这个查询,如下图所示.我收到语法错误

                  I've tried this query with both commas and "AND" statements as pictured below. I get a syntax error

                  出了点问题.您的 SQL 语法有误;查看与您的 MySQL 服务器版本相对应的手册,以了解在 ' 附近使用的正确语法,可以 24/7 全天候通过电话和电子邮件回答任何问题并为您提供帮助 ' 在第 1 行

                  Something went wrong.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 'are available 24/7 by phone and email to answer any questions and to assist you ' at line 1

                  每次我尝试这个查询:

                  $sql = mysql_query("UPDATE general
                      SET bookabandheading = $_POST[bookabandheading 
                      AND bookaband = $_POST[bookaband]
                      AND contactus = $_POST[contactus]
                      AND aboutuslisten = $_POST[aboutuslisten]
                      AND contactusheading = $_POST[contactusheading]
                      AND nightclubsheading = $_POST[nightclubsheading]
                      AND acousticheading = $_POST[acousticheading]
                      AND schoolsheading = $_POST[schoolsheading]
                      AND privateheading = $_POST[privateheading]
                      AND concertsheading = $_POST[concertsheading]
                      AND festivalsheading = $_POST[festivalsheading]
                      AND submissions = $_POST[submissions]
                      AND interns = $_POST[interns]
                      AND managementbio = $_POST[managementbio]
                      AND latestnews = $_POST[latestnews]
                      AND artistofthemonth = $_POST[artistofthemonth]
                      AND artistofthemonthphoto = $_POST[artistofthemonthphoto]
                      AND artistofthemonthid = $_POST[artistofthemonthid]
                      AND listentoourartists = $_POST[listentoourartists]
                      AND musicianswanted = $_POST[musicianswanted]
                      AND aboutus = $_POST[aboutus]
                      AND bshowcases = $_POST[bshowcases]
                      AND bandavails = $_POST[bandavails]");
                  

                  查询在另一个 VPS 上的不同数据库中工作,但我只是迁移了服务器,它不再工作.非常感谢任何帮助!

                  The query worked in a different database on another VPS, but I just migrated servers and it no longer works. Any help is greatly appeciated!

                  推荐答案

                  虽然主要问题是您在 bookamandheading 之后错过了右括号,但我仍然建议您重构此请求,例如:

                  While the main problem is that you missed the closing bracket after bookamandheading, still I would like to advise you to refactor this request for example like this:

                  $keys = array("bookabandheading", "bookaband", "contactus", "aboutuslisten",
                                "contactusheading", "nightclubsheading", "acousticheading",
                                "schoolsheading", "privateheading", "concertsheading",
                                "festivalsheading", "submissions", "interns", "managementbio",
                                "latestnews", "artistofthemonth", "artistofthemonthphoto",
                                "artistofthemonthid", "listentoourartists", "musicianswanted",
                                "aboutus", "bshowcases", "bandavails");
                  $set = array();
                  foreach ($keys as $key) {
                      $set[] = sprintf(" %s = '%s' ", $key, mysql_escape_string($_POST[$key]));
                  }
                  $sql = mysql_query("UPDATE general SET " . implode(", ", $set));
                  

                  通过转义输入更容易维护,也更安全.

                  It is much easier to maintain and also a bit more secure by escaping the input.

                  更新:添加 where 语句示例

                  Update: add where statement example

                  $where = array();
                  $where[] = sprintf(" some_string = '%s' ", mysql_escape_string($some_string));
                  $where[] = sprintf(" some_integer = %d ", $some_integer);
                  $where = " WHERE " . implode(" AND ", $where);
                  $sql = mysql_query("UPDATE general SET " . implode(", ", $set) . " " . $where);
                  

                  这篇关于具有多列的 PHP MySQL 更新集查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的问题)
                    <legend id='oIlqJ'><style id='oIlqJ'><dir id='oIlqJ'><q id='oIlqJ'></q></dir></style></legend>
                  • <small id='oIlqJ'></small><noframes id='oIlqJ'>

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

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