vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Option Data From Table (https://vborg.vbsupport.ru/showthread.php?t=223405)

SorentoUltimate 09-17-2009 07:30 AM

Option Data From Table
 
Hello, i writeing a new addon and i have a problem.
i try to load data from a ta table for an option but i cannot make it !!!!

Option Code

Code:

select:eval
require_once(DIR . '/includes/functions_colors.php');
$options = fetch_colors_options_array();

_

functions_colors.php

Code:

<?php

error_reporting(E_ALL & ~E_NOTICE);

// ###################### Fetch Colors as Options #######################
// Return Colors Options Array
function fetch_colors_options_array()
{

  global $vbulletin;
  $out = array();   

  // fetch Colors
  $getcolors = $db->query_read("
    SELECT colorid, colorname
    FROM `" . TABLE_PREFIX . "colors`
  ");
   
    echo 'After Get';

  while ($colorrow = $db->fetch_array($getcolors))
  {
    $out["$colorrow[colorid]"] = "$colorrow[colorname]";
  }   

  return $out;

}

?>

_

Error :

Fatal error: Call to a member function on a non-object in /......./......./......./......./forum/includes/functions_colors.php on line 14

Lynne 09-17-2009 05:54 PM

Did you include global.php or init.php in your main file? If not, $db->query_read is not valid since it is a vbulletin thing.

SorentoUltimate 09-17-2009 06:28 PM

no i don't include,

need to include global.php or init.php to functions_colors.php or to plugin i call function ???

Lynne 09-17-2009 06:55 PM

Well, or you need to use standard php language to access the database.

SorentoUltimate 09-17-2009 06:59 PM

Quote:

Originally Posted by Lynne (Post 1886571)
Well, or you need to use standard php language to access the database.

Where to put global.php and(or) init.php ??

Lynne 09-17-2009 07:04 PM

Well, you need to include it before you make any database calls. So, in either file I would think is fine. Depends on if you will need it again or not.

SorentoUltimate 09-17-2009 07:06 PM

Quote:

Originally Posted by Lynne (Post 1886582)
Well, you need to include it before you make any database calls. So, in either file I would think is fine. Depends on if you will need it again or not.

ok, thanks
i try and if i have any more problem i write it

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

i put require_once('./global.php'); at option code

and now the option code are

select:eval
require_once('./global.php');
require_once(DIR . '/includes/functions_colors.php');
$options = fetch_colors_options_array();

but now the error are :

Fatal error: Call to a member function on a non-object in /......./......./......./......./forum/global.php on line 242


All times are GMT. The time now is 07:14 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.01428 seconds
  • Memory Usage 1,725KB
  • 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
  • (2)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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