Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts

    Notice: Object of class stdClass could not be converted to int

    hi guys, im getting an error:

    Code:
    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:

    PHP Code:
    if ($now_online $most_online){ 
    the whole code is:

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

    $timenow=time();

    $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.

    Thanks

    Dan
    Last edited by Dan13071992; 01-17-2012 at 01:14 AM.
    http://360-tactics.co.uk/forum/index.php

    Crime-Wave

    please post your code wrapped in tags
    please post your PHP wrapped in tags

  • #2
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Hi Dan. I remember talking to you about how to use objects with mysql_fetch_object .

    $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:
    PHP Code:
    UPDATE site_stats SET mostonline=(SELECT COUNT(*) FROM users WHERE online>$timenowWHERE id=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
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • #3
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    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.
    http://360-tactics.co.uk/forum/index.php

    Crime-Wave

    please post your code wrapped in tags
    please post your PHP wrapped in tags

  • #4
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    it seems to be working

    thanks BP
    http://360-tactics.co.uk/forum/index.php

    Crime-Wave

    please post your code wrapped in tags
    please post your PHP wrapped in tags

  • #5
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    No problem
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •