Update running multiple times in a single instance

Asked

Viewed 147 times

1

I have had a problem in my system that some pages that do UPDATE in stock tables sometimes run multiple times, so the page was not loaded twice because I created a protection account this. A single instance mysql_query is for some reason running multiple times in my Mysql. Does anyone have any idea why the bug? Has anyone gone through it? I’m not using PDO, it would be a solution?

  • Would a double click cause this? Also enter php code.

  • 1

    The mysql_query function will be discontinued. Why don’t you publish your code so we can evaluate the problem?

  • 1

    The right thing is for you to post the code so that we can analyze it and give you backing.

2 answers

0


So this problem occurs in many of my scripts, I thought it was a double click or a refresh or even back in the history, but I created a protection against it, the curious thing is that the error happens only a few times, once a week on a page that is accessed 50 times a day... Follow an example of the code:

//This bypasses refresh and double click

if($_SESSION['DADOS'] != $_REQUEST){
   $sql = "UPDATE estoque SET estoque = (estoque - '" . $_REQUEST['quantidade'] . "') WHERE codigo = '" . $_REQUEST['codigo'] . "'";
   $query = mysql_query($sql);
}

-1

The function mysql_COMANDOS is obsolete, soon it will not be possible to use it, even for security reasons. The Solution is you use the functions mysqli_COMANDOS(This commands means all possible words) or else make the connection via PDO.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.