Update running multiple times in a single instance

1

I have had a problem with my system that some pages that do UPDATE in the inventory tables sometimes run multiple times, so the page was not loaded twice because I created a protection account. A single mysql_query instance is somehow running multiple times on my MySQL.  Does anyone have any idea of the reason for the bug? Has anyone ever experienced this? I'm not using PDO, would it be a solution?

    
asked by anonymous 13.07.2015 / 19:18

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 history, but I created a protection against this, the more curious is that the error happens only a few times , a once a week thing on a page that is accessed about 50 times a day ...  Here is an example of the code:

// this circumvents refresh and double click

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

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

    
13.07.2015 / 21:16