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

  • <tfoot id='pZv5j'></tfoot>

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

        多次运行 MySQL INSERT Query(将值插入多个表)

        Run MySQL INSERT Query multiple times (insert values into multiple tables)(多次运行 MySQL INSERT Query(将值插入多个表))

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

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

                  本文介绍了多次运行 MySQL INSERT Query(将值插入多个表)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  基本上,我有 3 张桌子;用户和项目,然后我有'users_projects'来允许一对多的形成.当用户添加项目时,我需要存储项目信息,然后将userid"和projectid"存储在 usersprojects 表中.听起来很直接,但我认为语法有问题!?

                  basically, I have 3 tables; users and projects, then I have 'users_projects' to allow the one-to-many formation. When a user adds a project, I need the project information stored and then the 'userid' and 'projectid' stored in the usersprojects table. It sounds like its really straight forward but I'm having problems with the syntax I think!?

                  就目前而言,我将其作为我的 INSERT 查询(值进入 2 个不同的表):

                  As it stands, I have this as my INSERT queries (values going into 2 different tables):

                  $projectid = $_POST['projectid'];
                      $pname = $_POST['pname'];
                      $pdeadline = $_POST['pdeadline'];
                      $pdetails = $_POST['pdetails'];
                  
                      $userid = $_POST['userid'];
                  
                  $sql = "INSERT INTO projects (projectid, pname, pdeadline, pdetails) VALUES
                     ('{$projectid}','{$pname}','{$pdeadline}','{$pdetails}')";
                  
                  
                  $sql =  "INSERT INTO users_projects (userid, projectid) VALUES
                     ('{$userid}','{$projectid}')";
                  
                  $result = mysql_query($sql, $connection)
                      or die("MySQL Error: ".mysql_error());
                  header("Location: frontview.php");
                  exit();
                  

                  推荐答案

                  你只是忘记在每个查询之间执行 sql.添加

                  You simply forgot to execute the sql between each query. Add the

                   mysql_query($sql, $connection)
                      or die("MySQL Error: ".mysql_error());
                  

                  在每个查询之间,你应该没问题.

                  between each query and you are supposed to be fine.

                  btw (1) 在 sql 日志(在 /var/log/mysql/ 下)使用 tail -f 打开控制台进行测试总是有帮助的
                  b.t.w.(2) 您的代码存在严重的安全问题.
                  b.t.w (3) 您可能要考虑使用 PDO/Mysqli 而不是旧的 mysql 扩展.b.t.w (4) 使用某种包装器(一个好的类)来接近数据库而不是直接在代码中的任何地方执行它会使您的生活变得更简单.

                  b.t.w (1) it always helpful to test with a console open with tail -f on the sql log (under /var/log/mysql/ )
                  b.t.w.(2) You are having heavy security issues in your code.
                  b.t.w (3) You might want to consider using PDO/Mysqli and not the old mysql extension. b.t.w (4) It would make your life simpler to use some kind of wrapper (a good class) to approach the DB and not do it directly everywhere in your code.

                  这篇关于多次运行 MySQL INSERT Query(将值插入多个表)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的问题)

                    • <tfoot id='sDqKt'></tfoot>
                      <legend id='sDqKt'><style id='sDqKt'><dir id='sDqKt'><q id='sDqKt'></q></dir></style></legend>

                        • <bdo id='sDqKt'></bdo><ul id='sDqKt'></ul>
                            <tbody id='sDqKt'></tbody>

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

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