Jump to content
MakeWebGames

yet another secure error


Legaci

Recommended Posts

$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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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:

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...