Legaci Posted June 17, 2013 Posted June 17, 2013 $q=$dbh->query("SELECT count(*) FROM userstats us LEFT JOIN users u ON us.userid=u.userid WHERE us.=? > ? AND us.userid != ? AND u.user_level != 0", $mykey, $stat, $userid) ; return $db->fetch_single($q)+1; there is an error with this this is the message Fatal error: Call to a member function query() on a non-object in /home/bravelan/public_html/global_func.php on line 285 Quote
Dayo Posted June 17, 2013 Posted June 17, 2013 You have a problem with the function query look at the variable/class calling it rather then just post the awnser ill help you fix it yourself ;) Quote
Dominion Posted June 17, 2013 Posted June 17, 2013 When posting errors just the line rarely helps. Next time post a little both ways (e.g. 10 lines either side) or the whole function it's in. In this case take a look at another function in the same file using a query in it (e.g. itemtype_dropdown()). Take note of the first few lines. Quote
Legaci Posted June 17, 2013 Author Posted June 17, 2013 function get_rank($stat, $mykey) { global $db; global $ir,$userid,$c; $q=$dbh->query("SELECT count(*) FROM userstats us LEFT JOIN users u ON us.userid=u.userid WHERE us.=? > ? AND us.userid != ? AND u.user_level != 0", $mykey, $stat, $userid) ; return $db->fetch_single($q)+1; } this is the function Quote
KyleMassacre Posted June 17, 2013 Posted June 17, 2013 Since that class isn't a standard mc code class a lot of people won't know what your talking about but you have in the us.=? so remove the "=" Quote
KyleMassacre Posted June 17, 2013 Posted June 17, 2013 Should be $db->query not $dbh->query Its right Ian, he is using another class. But I think I remember him saying that he instantiated the class towards the bottom of his page and I didn't pay attention then but Legaci, call your new class the dbWrapper towards the top of your global func file Quote
Guest Posted June 17, 2013 Posted June 17, 2013 Its right Ian, he is using another class. But I think I remember him saying that he instantiated the class towards the bottom of his page and I didn't pay attention then but Legaci, call your new class the dbWrapper towards the top of your global func file Then surely he needs global $dbh? And why would you use $dbh for the query then $db for the result? :confused: Quote
KyleMassacre Posted June 17, 2013 Posted June 17, 2013 the class is still a work in progress ;) Atleast his db execution queries are binded properly using a mysqli class for now so he just needs to incorporate a fetch function for his queries Quote
Guest Posted June 17, 2013 Posted June 17, 2013 So confused, maybe that's where it is going wrong, possibly losing it after doing the query to when he wants the results? Wild guess, i'm totally lost with this one sorry Quote
KyleMassacre Posted June 17, 2013 Posted June 17, 2013 well I had him keep the original class for now because of gaps like this but here is the class he's using https://github.com/vjeux/MysqliWrapper/blob/master/src/mysqli-wrapper.php Quote
Legaci Posted June 17, 2013 Author Posted June 17, 2013 i removed to = but still the same problem is arising Quote
Dominion Posted June 17, 2013 Posted June 17, 2013 I assume $dbh is set somewhere? It needs to be used in the same way as $db meaning something is missing (global...). Quote
Legaci Posted June 17, 2013 Author Posted June 17, 2013 $dbh is in global is just an alteration to $db Quote
Legaci Posted June 17, 2013 Author Posted June 17, 2013 turns out is wasnt a Db query i was looking at it and new that wasnt correct so here is my resolved problem function get_rank($stat, $mykey) { global $ir,$userid,$c; $q=mysql_query("SELECT count(*) FROM userstats us LEFT JOIN users u ON us.userid=u.userid WHERE us.$mykey > $stat AND us.userid != $userid AND u.user_level != 0", $c) ; return mysql_result($q,0,0)+1; } Thanks for the help Quote
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.