Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 03 Aug 2008, 20:25
PntSingularity's Avatar
PntSingularity PntSingularity is offline
 
Join Date: Feb 2007
Real name: PointSingularity
db query @ postbit_display_start

I'm trying to run db queries at the hook postbit_display_start, but for some reason it doesn't seem to work...

When I try this line:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

...the code fails and showthread.php returns an empty page.

Ideas?


EDIT:
Nevermind, it seems it works when I use the "showthread_postbit_create" hook instead.

Now I need to figure out why I get "Resource id #x" instead of the data I'm looking for... *sigh*
__________________
Online Roleplaying Community
2 d 4

Last edited by PntSingularity; 03 Aug 2008 at 21:07.
Reply With Quote
  #2  
Old 03 Aug 2008, 21:42
MoT3rror MoT3rror is offline
 
Join Date: Mar 2007
Change your function to query_first then query_read.
Reply With Quote
  #3  
Old 03 Aug 2008, 22:35
Opserty Opserty is offline
 
Join Date: Apr 2007
In the postbit_* hooks you will most likely need to use the $this->registry->db variable or the $vbulletin->db variable as those hooks are executed within a class, if I remember correctly.
Reply With Quote
  #4  
Old 05 Aug 2008, 01:00
PntSingularity's Avatar
PntSingularity PntSingularity is offline
 
Join Date: Feb 2007
Real name: PointSingularity
Originally Posted by Opserty View Post
In the postbit_* hooks you will most likely need to use the $this->registry->db variable or the $vbulletin->db variable as those hooks are executed within a class, if I remember correctly.
Thanks. But like I said I switched onto another hook that worked better. Thanks for the info though, might need to use those hooks some other time.

Originally Posted by MoT3rror View Post
Change your function to query_first then query_read.
Umm... why? Unless I'm mistaken query_first reads only the first line whereas query_read reads ALL lines (including the first).


Anyways, I solved the resource id thingy with fetch_array.
__________________
Online Roleplaying Community
2 d 4
Reply With Quote
  #5  
Old 05 Aug 2008, 04:43
MoT3rror MoT3rror is offline
 
Join Date: Mar 2007
Well query_read only does like mysql_query but query_first does mysql_query and fetch_array both and returns the array. Plus you are only pulling out one row with that query.
Reply With Quote
  #6  
Old 05 Aug 2008, 05:07
PntSingularity's Avatar
PntSingularity PntSingularity is offline
 
Join Date: Feb 2007
Real name: PointSingularity
Originally Posted by MoT3rror View Post
Well query_read only does like mysql_query but query_first does mysql_query and fetch_array both and returns the array. Plus you are only pulling out one row with that query.
Ah ok, now I understand. Thing is that I wanted all rows, I just hadn't figured out how to do that yet. I'm basically learning php while writing a plugin.
__________________
Online Roleplaying Community
2 d 4
Reply With Quote
  #7  
Old 05 Aug 2008, 08:23
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
To get more then 1 row, you will need to do your query_read() followed by a fetch_array() in a loop.
__________________
Marco van Herwaarden
Ex vBulletin.org Coordinator
Reply With Quote
  #8  
Old 05 Aug 2008, 08:41
PntSingularity's Avatar
PntSingularity PntSingularity is offline
 
Join Date: Feb 2007
Real name: PointSingularity
Originally Posted by Marco van Herwaarden View Post
To get more then 1 row, you will need to do your query_read() followed by a fetch_array() in a loop.
Thanks, but like I mentioned...
Originally Posted by PntSingularity View Post
Anyways, I solved the resource id thingy with fetch_array.
__________________
Online Roleplaying Community
2 d 4
Reply With Quote
  #9  
Old 20 Aug 2008, 02:05
sarahk's Avatar
sarahk sarahk is offline
 
Join Date: Jun 2004
Originally Posted by PntSingularity View Post
Anyways, I solved the resource id thingy with fetch_array.
I'm stuck on the same thing (so I appreciate the thread). PntSingularity I'm getting none of the post information when I change to the hook you use! How did you access the post data?

turns out the syntax I was after in the original hook was

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Property Management Services
Simple SEO Blog
Reply With Quote
  #10  
Old 20 Aug 2008, 05:21
PntSingularity's Avatar
PntSingularity PntSingularity is offline
 
Join Date: Feb 2007
Real name: PointSingularity
Originally Posted by sarahk View Post
I'm stuck on the same thing (so I appreciate the thread). PntSingularity I'm getting none of the post information when I change to the hook you use! How did you access the post data?

turns out the syntax I was after in the original hook was

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.
I don't think I ever tried a query_first there. However, I've used the variable Opserty mentioned there with query_read.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

If you're using showthread_postbit_create you should simply use $db->query (or query_first, query_read or query_write).

If you're not already doing that, you might want to ssh to the server (if you have that possibility) and tail the error log to receive real-time error reporting.
In a command shell (cmd/terminal):

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Replace example.com with your domain and enter your root password.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Of course, your log may be in a slightly different location. I'm running apache on Fedora 9 myself.
__________________
Online Roleplaying Community
2 d 4
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 05:34.

Layout Options | Width: Wide Color: