-1

I've already looked through other questions but couldn't find an answer to this specific problem since it seems its all about the Chrome browser.

I stripped down my code to debug this problem and the only thing I'm executing now is loading my database and doing an INSERT.

However it always inserts two rows instead of one row.

Then I tested this with Firefox and there are no problems. I also disabled all my Chrome Extensions and it's still unchanged. I can't figure out what else might be causing this. Like I said, it works in other browsers.

AlexioVay
  • 4,338
  • 2
  • 31
  • 49
  • 2
    It looks like you want us to write some code for you. While many users are willing to produce code for a coder in distress, they usually only help when the poster has already tried to solve the problem on their own. A good way to demonstrate this effort is to include the code you've written so far, example input (if there is any), the expected output, and the output you actually get (console output, tracebacks, etc.). The more detail you provide, the more answers you are likely to receive. Check the [FAQ] and [ask]. – sauntimo Jul 20 '17 at 23:31
  • I recommend you read **[what topics you can ask about here](https://stackoverflow.com/help/on-topic)** and then **[how to ask perfect question](https://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/)**, next **[how to create Minimal, Complete and Verifable example](https://stackoverflow.com/help/mcve)**. Then edit your question accordingly to attract more attention and get possibly help. – Marcin Orlowski Jul 20 '17 at 23:32
  • 2
    Server-side code acting different depending on the browser, um, I don't even want to see that code :-D – Capsule Jul 20 '17 at 23:35
  • What? No. I dont want code. I want explanations. I just didnt post my code since its obvious what I told you my file is executing: db-connect + Insert. Nothing more. I also told you its all about the Chrome browser. So what code do you even want then? – AlexioVay Jul 20 '17 at 23:47
  • Like `phlare` pointed out its a known issue/bug: https://stackoverflow.com/questions/4460661/what-to-do-with-chrome-sending-extra-requests This question is very similiar to mine and it's not like I'm new here, so I don't get your There-is-no-code-I-have-to-downvote-attitude. – AlexioVay Jul 21 '17 at 02:26

2 Answers2

1

there is some discussion about chrome making multiple requests here

the gist seems to be that there are some things that could cause chrome to make an additional request, including (but not limited to):

  • link tags with an empty href property <link rel="shortcut" href="">
  • image, iframe, or scripts tags with an empty or '#' src property <img src="#">
  • chrome fetching the favicon

do any of those apply?

regardless of what is causing the double GET, a good solution would be to be to follow standard web development best practices: don't change application state as a result of a GET call. Require a POST.

phlare
  • 318
  • 3
  • 11
  • in the insert itself are you saving the date and the user_Id ? you could make the table unique on the combination of those two columns to help prevent duplicates – phlare Jul 21 '17 at 15:53
0

Server side code (e.g. PHP script) does not depend of your browser. So it couldn't behave differently in different browsers.

But yes, in some cases you may have your code executed two times for single page hit.

Lets assume you have a code that inserts new row every time your page has been visited (for example: old-school visits counter). When using Google Chrome you may be surprised, cause you'll get two inserted rows per single page hit. That happens because Google Chrome makes second request to page just for getting favicon.

Other possibility is an weird condition in your code. Eg. if it is chrome, do something else/more

piotr
  • 1,282
  • 1
  • 8
  • 20