PDA

View Full Version : Broken code....


noppid
05-28-2003, 08:59 PM
This snippet is from index.php, it's supposed to only update when the number of users online is equal or greater then the previous stat. Problem is this template keeps getting updated with a lower number.


if ((int)$maxusers[0] <= $totalonline) {
$time = time();
$maxloggedin = "$totalonline " . $time;
$DB_site->query("UPDATE template SET template='$maxloggedin' WHERE title='maxloggedin'");
$maxusers[0] = $totalonline;
$maxusers[1] = $time;
}


Is there another instance of it anywhere that is breaking it or is this a bug?

It's really annoying me.

Regards

filburt1
05-28-2003, 09:09 PM
For one thing, you don't need to usually typecast in PHP. It handles variable comparisons intelligently.

Also, shouldn't it be >= anyway?

noppid
05-28-2003, 09:28 PM
I checked and double checked a virgin index.php. The code is exactly as it appears in the distributed file of vB version 2.3.0.

Boofo
05-28-2003, 09:57 PM
If you find a fix for this, please let us know. ;)

filburt1
05-28-2003, 10:04 PM
$totalonline probably isn't set, so it's evaluating to 0.

A fun trick is to copy that line of code and encapusate it in quotes in an echo statement (i.e., echo "that line of code;"). You'll see (mostly) what PHP is doing.

noppid
05-28-2003, 11:21 PM
Since it's not code that I've modified, I'll call it a bug and leave it to the authors of vB.

Thanks

Boofo
05-28-2003, 11:48 PM
If you hear anything on it, we would be interested.

noppid
05-29-2003, 06:03 PM
Holding steady and not decrementing since adding....


if ( (int)$maxusers[0] <= $totalonline && $maxusers[0] != 0 ) {

Katman
06-25-2003, 04:07 PM
All that does is change the number to a date, still not working correctly.

noppid
06-26-2003, 02:30 PM
Yesterday at 01:07 PM Katman said this in Post #9 (https://vborg.vbsupport.ru/showthread.php?postid=412645#post412645)
All that does is change the number to a date, still not working correctly.

Could you have made a typo? It's working fine here still and there is a number displayed, not a date. The edit should not effect the display. We only change the condition on which it will update the DB.


Most users ever online was 16 on 06-18-2003 at 01:13 PM.