<bdo id='ZBqtZ'></bdo><ul id='ZBqtZ'></ul>
  1. <small id='ZBqtZ'></small><noframes id='ZBqtZ'>

  2. <tfoot id='ZBqtZ'></tfoot>
    <legend id='ZBqtZ'><style id='ZBqtZ'><dir id='ZBqtZ'><q id='ZBqtZ'></q></dir></style></legend>

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

      PHP:在单个查询中更新多个 MySQL 字段

      PHP: Update multiple MySQL fields in single query(PHP:在单个查询中更新多个 MySQL 字段)

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

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

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

                本文介绍了PHP:在单个查询中更新多个 MySQL 字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我基本上只是想更新表中的多个值.解决此问题的最佳方法是什么?这是当前代码:

                I am basically just trying to update multiple values in my table. What would be the best way to go about this? Here is the current code:

                $postsPerPage = $_POST['postsPerPage'];
                $style = $_POST['style'];
                
                mysql_connect ("localhost", "user", "pass") or die ('Error: ' . mysql_error());
                mysql_select_db ("db");
                
                mysql_query("UPDATE settings SET postsPerPage = $postsPerPage WHERE id = '1'") or die(mysql_error());
                

                我想包含的另一个更新是:

                The other update I want to include is:

                mysql_query("UPDATE settings SET style = $style WHERE id = '1'") or die(mysql_error());
                

                谢谢!

                推荐答案

                使用逗号分隔添加多个列:

                Add your multiple columns with comma separations:

                UPDATE settings SET postsPerPage = $postsPerPage, style= $style WHERE id = '1'
                

                但是,您没有清理您的输入?这意味着任何随机黑客都可能破坏您的数据库.看到这个问题:什么是清理用户输入的最佳方法用 PHP 吗?

                However, you're not sanitizing your inputs?? This would mean any random hacker could destroy your database. See this question: What's the best method for sanitizing user input with PHP?

                另外,样式是数字还是字符串?我假设一个字符串,所以它需要被引用.

                Also, is style a number or a string? I'm assuming a string, so it would need to be quoted.

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

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

                相关文档推荐

                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 的问题)
                smtp gmail server php mailer not working(smtp gmail服务器php邮件程序不工作)
                Email goes in spam when I send it via others SMTP server(当我通过其他 SMTP 服务器发送电子邮件时,电子邮件进入垃圾邮件)

                    <tbody id='1BomM'></tbody>

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

                1. <tfoot id='1BomM'></tfoot>

                    • <legend id='1BomM'><style id='1BomM'><dir id='1BomM'><q id='1BomM'></q></dir></style></legend>
                          <bdo id='1BomM'></bdo><ul id='1BomM'></ul>

                          <small id='1BomM'></small><noframes id='1BomM'>