Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-09-2012, 03:35 AM
Kyojii Kyojii is offline
 
Join Date: Jun 2008
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Call to a member function query_read() on a non-object

I seem to run into this problem a lot and it's always a pain to fix. This is being used to make a bbcode with this mod: https://vborg.vbsupport.ru/showthrea...44#post2346244 .

PHP Code:
<?php
require_once('./global.php');
$query $db->query_read("SELECT `userid`, `username` FROM " TABLE_PREFIX "user WHERE UPPER(`username`) = UPPER(".$value.")");
$user $db->fetch_array($query);

$avatar fetch_avatar_url($user['userid']);
$avatar = ($avatar['hascustom']) ? $avatar[0].'&amp;type=thumb' $avatar[0];

$url fetch_seo_url('member', array('userid' => $users['userid'], 'username' => $users['username']), array(), 'userid''username');
$output "<img style='height: 16px;' src='".$avatar."'><a href='".$url."</a>";

return 
$output;
?>

I added the require_once on global to try and fix it but it didn't work. Every time I have this problem I always find this as well: https://vborg.vbsupport.ru/showthread.php?t=235092 but that never fixed it either. Changing the query to vB::$db->query_read(" simply changes the error saying that the class vB isn't defined. also using $vbulletin->db->query_read doesn't seem to solve the problem either.
Reply With Quote
  #2  
Old 07-09-2012, 03:50 AM
Badshah93 Badshah93 is offline
 
Join Date: Jun 2010
Location: India
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Below this code
Code:
require_once('./global.php');
Add
Code:
global $db;
Reply With Quote
  #3  
Old 07-09-2012, 04:47 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I prefer to have $vbulletin global and use $vbulletin->db.
Reply With Quote
  #4  
Old 07-09-2012, 05:20 AM
Badshah93 Badshah93 is offline
 
Join Date: Jun 2010
Location: India
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Below this code
Code:
require_once('./global.php');
Add
Code:
global $db;
Code:
or you change $db-> with $vbulletin->db
and no need of globalizing $vbulletin as global.php is called.

Quote:
also using $vbulletin->db->query_read doesn't seem to solve the problem either.
its because in next line you are using
Code:
$db->fetch_array
Reply With Quote
  #5  
Old 07-09-2012, 06:34 AM
Kyojii Kyojii is offline
 
Join Date: Jun 2008
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks guys.

--------------- Added [DATE]1341819639[/DATE] at [TIME]1341819639[/TIME] ---------------

Quote:
Originally Posted by Badshah93 View Post
Code:
or you change $db-> with $vbulletin->db
and no need of globalizing $vbulletin as global.php is called.



its because in next line you are using
Code:
$db->fetch_array
Nope, globalizing $db works however even replacing both lines with $vbulletin->db the error occurs.
Reply With Quote
  #6  
Old 07-09-2012, 08:24 AM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Are you using this within a hook? If so, you should remove that require because global.php has already been included.
Reply With Quote
  #7  
Old 07-09-2012, 08:40 AM
Badshah93 Badshah93 is offline
 
Join Date: Jun 2010
Location: India
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Kyojii View Post
Thanks guys.

--------------- Added [DATE]1341819639[/DATE] at [TIME]1341819639[/TIME] ---------------



Nope, globalizing $db works however even replacing both lines with $vbulletin->db the error occurs.
you can use this also in place of $db.
Code:
$GLOBALS['vbulletin']->db
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 08:26 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.10004 seconds
  • Memory Usage 2,232KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (9)bbcode_code
  • (1)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete