darkfreaks Posted February 7, 2008 Share Posted February 7, 2008 so how would i fix my code so it does not produce thise error? Line: <?php $users = $qls->online_users();?> Quote Link to comment https://forums.phpfreaks.com/topic/89857-call-to-function-on-a-non-object/ Share on other sites More sharing options...
rhodesa Posted February 7, 2008 Share Posted February 7, 2008 At that point in the code, $qls has not been declared as an instance of a class. Without knowing more code, it's impossible to tell you how to fix it. Are you working with code you wrote or someone else's? Quote Link to comment https://forums.phpfreaks.com/topic/89857-call-to-function-on-a-non-object/#findComment-460528 Share on other sites More sharing options...
Northern Flame Posted February 7, 2008 Share Posted February 7, 2008 can we see more code? Quote Link to comment https://forums.phpfreaks.com/topic/89857-call-to-function-on-a-non-object/#findComment-460529 Share on other sites More sharing options...
darkfreaks Posted February 7, 2008 Author Share Posted February 7, 2008 Code: <?php define('QUADODO_IN_SYSTEM', true); $query=trim(mysql_real_escape_string($query)); include('config.php'); $query = "SELECT * FROM vc_users WHERE username='$u'"; $result = mysql_query($query); $num=mysql_num_rows($result); mysql_close(); $i=0; while ($i < $num) { $logname = stripslashes($qls->user_info['username']); $header = mysql_result($result,$i,"header"); $group_id = mysql_result($result,$i,"group_id"); $dpic = mysql_result($result,$i,"dpic"); $privatecomments = mysql_result($result,$i,"privatecomments"); $invisible = mysql_result($result,$i,"invisible"); if ($group_id=="1") { ?> PLEASE DO NOT bother <?php echo $u; ?> with issues like:<br> reporting nudity (unless its a hot girl than report right away)<br> complaining about other users (This isnt VF)<br> any other site-related problems (We already know about the bugs)<br> ALL issues should be sent to:<br> <a href="../profile/admin">The Admin Profile</a> <p> <?php }; if ($group_id=="4") { ?> PLEASE DO NOT bother <?php echo $u; ?> with issues like:<br> reporting nudity (unless its a hot girl than report right away)<br> complaining about other users (This isnt VF)<br> any other site-related problems (We already know about the bugs)<br> ALL issues should be sent to:<br> <a href="../profile/admin">The Admin Profile</a> <p> <?php }; if ($u=="admin") { echo "PLEASE LEAVE YOUR REPORT BELOW AND WE WILL REPLY AS SOON AS POSSIBLE<br>"; }; ?> <form name="sendcomment" id="sendcomment" method="post" action="commentsleft.php"> Leave a comment for<br> <img src="gallery/<?php echo $dpic; ?>" border="0" class="thumbnail2"><br> <?php echo $u; ?> <br> <?php if ($invisible=="yes") { echo "[invisible]"; }; if ($invisible=="no") { $users = $qls->online_users(); $online_count = count($users); $online = false; for ($x = 0; $x < $online_count; $x++) { if ($users[$x]['username'] == $u) { $online = true; break; } } if ($online === true) { echo "<font color='Lime'>[Online]</font>"; } else { echo "<font color='Red'>[Offline]</font>"; } }; ?> <br> <input type="hidden" name="date" id="date" value="<?php $date_time = date('l M d, Y g:i A'); echo ($date_time); ?>(GMT)"> <input type="hidden" name="username" id="username" value="<?php echo $u; ?>"><br> <input type="hidden" name="fname" id="fname" value="<?php echo $logname; ?>"><br> <textarea rows="10" cols="50" name="message"> <?php echo $message; ?> </textarea> <br> <?php if($username=="admin") { echo "<input type='hidden' name='inbox' value='yes'>"; }else{ ?> Send to Inbox? <input type="checkbox" name="inbox" value="yes" <?php if($reply=="1") { echo "checked"; }; ?>> <?php }; ?> <?php if ($group_id=="1") { if ($privatecomments=="yes") { echo " Make private? <input type=\"checkbox\" name=\"private\" id=\"private\" value=\"yes\">"; }else{ echo ""; }; }; if ($group_id=="3") { if ($privatecomments=="yes") { echo " Make private? <input type=\"checkbox\" name=\"private\" id=\"private\" value=\"yes\">"; }else{ echo ""; }; }; if ($group_id=="4") { if ($privatecomments=="yes") { echo " Make private? <input type=\"checkbox\" name=\"private\" id=\"private\" value=\"yes\">"; }else{ echo ""; }; }; if ($group_id=="5") { if ($privatecomments=="yes") { echo " Make private? <input type=\"checkbox\" name=\"private\" id=\"private\" value=\"yes\">"; }else{ echo ""; }; }; ?> <br> <input type="hidden" name="new" id="new" value="yes"><br> <input type="submit" id="submit" name="submit" value=" Send Message "> <br> </form> <?php }; $i++; include ('includes/footer.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/89857-call-to-function-on-a-non-object/#findComment-460532 Share on other sites More sharing options...
rhodesa Posted February 7, 2008 Share Posted February 7, 2008 $qls needs to be defined somewhere as an instance of a class. Do you know what class it is supposed to be an instance of? Quote Link to comment https://forums.phpfreaks.com/topic/89857-call-to-function-on-a-non-object/#findComment-460537 Share on other sites More sharing options...
darkfreaks Posted February 7, 2008 Author Share Posted February 7, 2008 it is in the security class so how would i make reference to it? Quote Link to comment https://forums.phpfreaks.com/topic/89857-call-to-function-on-a-non-object/#findComment-460545 Share on other sites More sharing options...
Northern Flame Posted February 7, 2008 Share Posted February 7, 2008 i dont see where you establish the security class Quote Link to comment https://forums.phpfreaks.com/topic/89857-call-to-function-on-a-non-object/#findComment-460549 Share on other sites More sharing options...
darkfreaks Posted February 7, 2008 Author Share Posted February 7, 2008 it must have gotten deleted but in another file there is osmething like <?php $username = $qls->Security->make_safe($_GET['u']);?> ?> Quote Link to comment https://forums.phpfreaks.com/topic/89857-call-to-function-on-a-non-object/#findComment-460553 Share on other sites More sharing options...
rhodesa Posted February 7, 2008 Share Posted February 7, 2008 In the file with that line...are there any other calls to set $qls, like $qls = new ClassName(); or does it have some more included files that the page with errors isn't including? Quote Link to comment https://forums.phpfreaks.com/topic/89857-call-to-function-on-a-non-object/#findComment-460558 Share on other sites More sharing options...
Northern Flame Posted February 7, 2008 Share Posted February 7, 2008 first you need to establish the data inside the class, heres a good tutorial that helped me learn how to use classes http://forums.tizag.com/showthread.php?t=1815 Quote Link to comment https://forums.phpfreaks.com/topic/89857-call-to-function-on-a-non-object/#findComment-460559 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.