Insert query on page load, inserts twice?(在页面加载时插入查询,插入两次?)
问题描述
在我的游戏页面上,我有一个他们玩游戏的页面.在那个页面上我有一个查询
On my games page, I have a page where they play a game. On that page I have a query
$insert_user_activity = mysql_query("INSERT INTO game_activity (user_id,user_full_name,game_id,game_name) values ('$user_id','$full_name','$browser_id','$game_title')");
它将它记录到我的数据库中,它只是独立存在,当我刷新页面时,由于某种原因它被提交到数据库两次.
Which will log it into my database, it's just sitting on its own and when I refresh the page, it is submitted to the database twice for some reason.
推荐答案
你的前端控制器逻辑错误.
对您的网站发出的每个请求都会调用您执行此查询的页面,无论它是正确的请求还是对不存在的资源的调用.
The page where you are executing this query is called on every request made to your site, no matter whether it's a proper request or a call to a non-existent resource.
您必须更改前端控制器的逻辑,使其不会针对无效请求运行应用程序.否则网站上线时将不会有一个而是数千个错误插入.
You must change the logic of the front controller so it wouldn't run the application for the invalid requests. Otherwise there will be not one but thousands false inserts when the site goes live.
这篇关于在页面加载时插入查询,插入两次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在页面加载时插入查询,插入两次?
基础教程推荐
- 在PHP中根据W3C规范Unicode 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何替换eregi() 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
