Re: mysql problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jed R. Brubaker wrote:
> I could use a lead on a problem. I just don't know where to start.
>
> I have a PHP script that populates a database table. No big deal. It
> creates
> mailing labels. However, a weird things keeps happening - every once in a
> while, a query is run twice. It is the same query, same information, even
> the same time (there is a now() in the query - and it is identical).
>
> So the question is a simple one - is this a PHP problem or a MySQL
> problem?
> Or somewhere in the MySQL extension? And how would I know?
>
> There is one clue to this otherwise vague problem. I believe that this
> predominantly happens when the database is under an above average load.
>
> I would appreciate any help that I might be able to get.

Possibly the users are clicking twice on "Submit" when the site is slow.

Try embedding an MD5 hash or some other random token in the FORM, and mark
them off as "used" when you INSERT a new row.  If a token is "used" just
ignore the insert.

Or, better yet, check that the values are the same and ignore it, and if
they are different, because the user used their "Back" button and
submitted new data, go ahead and INSERT.

It might *NOT* be users clicking too much, but that's USUALLY the cause,
and it's easy to detect and "do the right thing" once you embed something
in each FORM to uniquely identify it before they submit it back to you.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux