I have a chunk of code in a webpage that works like this, to rotate some
ads.. :

if ($row = mysql_fetch_array($getads)) {
                do {
                        $POS = $row[LASTPOS];
                        $ID = $row[ID];
                        if ($POS > $numads) {
                                $POS = 1;

                        $update = mysql_query("UPDATE adtracker set LASTPOS = '$POS' 
where ID =
                        echo $row[LINKLOC];

                } while ($row = mysql_fetch_array($getads));


so it grabs the last position that ad was in from the DB, increments it by
1, unless incrementing it would push it past the max # of ads, so it resets
the position to 1.

The problem is, the site gets a lot of traffic, and instead of the ads
retaining positions like:

1, 2, 3   or  2, 3, 1   or  3, 1, 2   as they should, I've seen it somehow
go to:

1, 1, 3,  or  2, 2, 1  etc.

So I guess what is happening is that when 2 people hit the page at the exact
same time, it's getting updated values out of the DB for some of the ads
before they are all updated.. how can I go about controlling this?


PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to