vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Non-object Issue (https://vborg.vbsupport.ru/showthread.php?t=167202)

The-Ensemble 01-07-2008 07:38 PM

Non-object Issue
 
Ok I have this line of text in my php functions admin file that keeps getting booted when executed. with the error

Fatal error: Call to a member function on a non-object in {file} on line 8

Line 8:
PHP Code:

  $mainsqry $vbulletin->db->query_read("SELECT favid, name, displayid FROM " TABLE_PREFIX "favavorites_main ORDER BY displayid"); 

Whats the problem? I've switched from $vbulletin->db to $db, that wasn't it, there query layout is the same as other parts of the file that works fine. I don't get what the problem is at all.

Help?

Opserty 01-07-2008 08:16 PM

Post the lines above this line. (One line on its own its only good for solving syntax errors :p)

Most likely the vBulletin backend/core is not initiating correctly.

Marco van Herwaarden 01-08-2008 06:59 AM

Is this code inside a function?

The-Ensemble 01-08-2008 07:17 AM

Yes the code is inside a function, heres the function.

PHP Code:

function get_mains() 
  {
  
$mainsqry $vbulletin->db->query_read("SELECT favid, name, displayid FROM " TABLE_PREFIX "favavorites_main ORDER BY displayid");
  
$recordsetm $db->fetch_array($mainsqry);
  while(
$record mysql_fetch_assoc($recordsetm)) {
    
$mains[$record['mainid']] = $record;
    
$mains[$record['mainid']][cats] = array();
  }
  
  return 
$mains;



Marco van Herwaarden 01-08-2008 07:38 AM

The add the following as the first line of the function:
PHP Code:

global $vbulletin


The-Ensemble 01-08-2008 07:43 AM

Thanks, I've added that and its rejecting the same line again.

Marco van Herwaarden 01-08-2008 08:03 AM

change it to:
PHP Code:

global $vbulletin$db

You use both $vbulletin and $db in your script.

Marco van Herwaarden 01-08-2008 08:06 AM

Also, why do you use:
PHP Code:

  $recordsetm $db->fetch_array($mainsqry);
  while(
$record mysql_fetch_assoc($recordsetm)) { 

instead of:
PHP Code:

  while($record $db->fetch_array($mainsqry)) { 


The-Ensemble 01-08-2008 08:27 AM

I was chopping and changing the coding various ways to see which part it was, I was going to revert it back after I'd got it working.


All times are GMT. The time now is 03:31 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01100 seconds
  • Memory Usage 1,731KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete