Log in

View Full Version : userid in query


Lea Verou
10-29-2005, 12:04 AM
I'm writing a plugin that has a query inside that "filters" the entries from a database field if the userid in the db field matches the user's id (it's a postbit modification). In the query I currently have it as $post[userid]. Should I use something else? I also tried $post['userid'] and even $post["userid"] (lol) but neither worked... :(

The error I get is Fatal error: Call to a member function on a non-object.

spongebobrox128
10-29-2005, 12:24 AM
Ok, postbit wouldnt be $post['whatever'], it would be something like this

$this->post['userid']

Hope that helps :)

Lea Verou
10-29-2005, 12:36 AM
Already tried this and it doesn't work... :(
Here's the query:

SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "thread WHERE postuserid = '$this->post['userid']'


I can tell it has to do with the quotes but what can I do with them?

spongebobrox128
10-29-2005, 12:40 AM
Ok, in what im showing you, itll just be PHP Code for a variable called SQL, I know why your code is not working (I think...)

$SQL = "SELECT COUNT(*) FROM " . TABLE_PREFIX . "thread WHERE postuserid = '" . $this->post['userid'] . "'";

use that, and run $SQL, as long as userid is correct var name, that SHOULD work.
EDIT: Fixed small error that causes big problems

Lea Verou
10-29-2005, 01:10 AM
Still the same error. :(
This is the whole code of the plugin so far:
$threadcountpst=$db->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "thread WHERE postuserid = '" . $this->post['userid'] . "'");

Adrian Schneider
10-29-2005, 01:33 AM
Try $vbulletin->db instead of $db.

Lea Verou
10-29-2005, 01:42 AM
That can't be the problem, I used the same syntax in another plugin that works correctly.