The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Howto get info from a mysql query? Resource ID #23 is all I get
I have this query: $activeusers = $DB_site->query("
SELECT user.*, usergroup.* FROM " . TABLE_PREFIX . "user AS user LEFT JOIN " . TABLE_PREFIX . "usergroup AS usergroup ON(usergroup.usergroupid=user.usergroupid) WHERE user.tsserver_timestamp != '' ORDER BY usergroup.orderid DESC, user.username ASC "); This returns "Resource id #23". Now this may sound stupid, but how do I get info from that? PS If it's in the wrong part, sorry, was kind of unsure where to put it since I got the query, just not the php :P |
#2
|
||||
|
||||
The forum is correct, that's not a forum for php allone, but for mysql html or js help as well.
As for your actual bug: what is returning Resource id23? the $DB_site->query() function returns a mysql result set (speak a resource) so are you trying to work on that resource itself without using a fetch_array? |
#3
|
||||
|
||||
I am not sure how to use fetch_array I took a look at the php.net manual but all the output I got was only one name instead of the two (that were on and met requirements) at the time.
|
#4
|
|||
|
|||
fetch_array is used to take the results from a query and turns them into arrays, making them easy to work with in php.
Lets take this for example: I want to get the 5 newest usernames from my database, but I want to put a bit of text on a new line under the last username returned from mySQL. So I write this line to query the data: PHP Code:
This is where fetch_array comes in. As stated before I want to add text under the last username mySQL returned, which means I need to loop over the results (look at them one at a time). For the loop operation I will use the while function, you will notice fetch_array is called within this function, this is the most common useage of $DB_site->fetch_array(); within vBulletin. So heres you basic code for the loop/fetch_array operation PHP Code:
|
#5
|
|||
|
|||
would it be possible to re-open this thread? i appreciate it is very old...
|
#6
|
|||
|
|||
Well you just did.....
But information in this thread does not apply to later vBulletin versions. Please open a new thread or look in our Articles section. |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|