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

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

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

      1. php在mysql数据库中运行一次并插入两次

        时间:2023-10-30

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

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

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

                <bdo id='djK9K'></bdo><ul id='djK9K'></ul>
                  <tbody id='djK9K'></tbody>

                1. 本文介绍了php在mysql数据库中运行一次并插入两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在下面有一个简单的代码.运行一次后,会将结果两次插入到 mysql 数据库中.

                  I've got a simple code below. After it's run once, it inserts results twice into the mysql database.

                  如果它基于页面上的 1 次刷新运行两次或请求两次,为什么输出只是 1 个结果?

                  if it run twice or request twice base on 1 refresh on the page, why the output is just 1 result?

                  我整天都在谷歌上搜索并努力解决这个问题.但是,我无法弄清楚这段代码有什么问题.代码在本地主机上运行完美,但是移到服务器后,问题就出现了.有没有人遇到过这样的事情?如何解决这个问题?

                  I have been googling for the whole day and struggling to resolve this issue. However, I failed to figure out what is wrong with this code. The code runs perfectly on localhost, but after it's moved to the server, the problem pops up. Has anyone faced something like this before? How can this problem be resolved?

                  完整代码:

                  <?php
                  $db=mysql_connect('localhost','zzzzzzz','xxxxxx') or die('Unable to connect.'.mysql_error());
                  mysql_select_db('test',$db) or die(mysql_error($db));
                  
                  $sql="INSERT INTO test_table(value,insert_time) VALUES ('testing','".time()."')";
                  $result=mysql_query($sql);
                  echo "result=".$result;
                  
                  $select="select * from test_table";
                  $rs=mysql_query($select);
                  while($row=mysql_fetch_array($rs)){
                  echo $row["test_id"]." -- ".$row["value"]." -- ".$row["insert_time"]."<br />";
                  }
                  ?>
                  

                  结果:
                  结果=1
                  1 -- 测试 -- 1298185509

                  RESULT:
                  result=1
                  1 -- testing -- 1298185509

                  但在数据库中:
                  test_id , value , insert_time
                  1、测试、1298185509
                  2、测试,1298185511

                  BUT IN DATABASE:
                  test_id , value , insert_time
                  1 , testing , 1298185509
                  2 , testing , 1298185511

                  推荐答案

                  我遇到和你一样的问题,这个问题只在我使用 Opera 或 chrome 时出现.

                  I'm facing the same issue as you, the problem only occus when I use Opera or chrome.

                  就我而言,我有一个 .htaccess 将所有内容都指向索引文件.浏览器自然会请求脚本两次,一次是自己的脚本,另一次是网站图标.

                  For my case, I have an .htaccess to point every thing to the index file. Naturally the browser will request the script twice, once for the script it self, the other is for the favicon.

                  解决方法:尝试编辑 .htaccess 以防止在浏览器请求 favicon.ico

                  The fix: Try to edit the .htaccess to prevent redirection to the index file when the browser is requesting for favicon.ico

                  这篇关于php在mysql数据库中运行一次并插入两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:DateTime 类的对象无法转换为字符串 下一篇:PHP mySQL - 将新记录插入表中,主键自动递增

                  相关文章

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

                    <small id='9nSXC'></small><noframes id='9nSXC'>

                    <tfoot id='9nSXC'></tfoot>
                      • <bdo id='9nSXC'></bdo><ul id='9nSXC'></ul>