View Full Version : Resolved Notice: Object of class stdClass could not be converted to int

01-17-2012, 12:04 AM
hi guys, im getting an error:

Notice: Object of class stdClass could not be converted to int in /home/tacticsc/domains/360-tactics.co.uk/public_html/crimewave/includes/inc-functions.php on line 108

it is really bugging me as i cant figure out what the problem is, and i just keep looking over line 108 and cant seem to find the problem, line 108 is:

if ($now_online > $most_online){

the whole code is:

$most_online=mysql_fetch_object(mysql_query("SELECT mostonline FROM site_stats WHERE id='1'"));


$now_online=mysql_num_rows(mysql_query("SELECT * FROM users WHERE online > '$timenow'"));

if ($now_online > $most_online){
mysql_query("UPDATE site_stats SET mostonline='$now_online' WHERE id='1'");


if anyone could point out what the problem is/give me a bit of help to figure this one out, that would be great.



01-17-2012, 12:31 AM
Hi Dan. I remember talking to you about how to use objects with mysql_fetch_object :p.

$most_online is an object with the property mostonline. So, you would use $most_online->mostonline.

But, I would let a mysql update query do all the work here. Something like:

UPDATE site_stats SET mostonline=(SELECT COUNT(*) FROM users WHERE online>$timenow) WHERE id=1 AND mostonline<(SELECT COUNT(*) FROM users WHERE online>$timenow)

Haven't tested that query, but I think it'll work. You should look into the more advanced features of mysql like I suggested :)

01-17-2012, 12:33 AM
will test it now and post back to you, i didnt think it could be done using the COUNT in mysql, but as you recommended the other day, i will carry on looking into these mysql features :)

cheers BP will post back shortly.

01-17-2012, 12:36 AM
it seems to be working :)

thanks BP :)

01-17-2012, 12:50 AM
No problem :)