vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Creating Plugin Error when adding query (https://vborg.vbsupport.ru/showthread.php?t=286902)

Jay- D 08-21-2012 12:00 PM

Creating Plugin Error when adding query
 
I'm writing my first plugin. I got to the point where my static code needed to be ported to the database. When I added in some simple code:


PHP Code:

$j $vbulletin->db->query_first_slave("SELECT 1+1"); 

This is just some test code, but it displays a white screen. No info, nothing. I'm guessing it's a 500 internal error. I have debugging on as well, with nothing be printed to screen. No logs are being created.

Does anyone have any advice?

Jay

kh99 08-21-2012 12:07 PM

It's probably a php error, and you have display_errors set to off. Just a guess, but you could try adding "global $vbulletin;" to the start of your code (depending on the hook you use, $vbulletin isn't always available unless you add that).

Simon Lloyd 08-21-2012 12:07 PM

It looks to me that you aren't querying the database, normal syntax would be "SELECT whatimlookingfor FROM mytablename WHERE whatimlookingforisin" that select 1+1 isn't a query to do anything as such.

Jay- D 08-21-2012 08:59 PM

Kevin, that was it! I needed a global for connection to the database. I hope this can help someone in the future.

Thank you!

And Simon, try that query on console, you'll see it is a valid query. I was doing that to make sure it wasn't my query that was messed up.

Here is the result fyi:

PHP Code:

Array
(
    [
1+1] => 2




All times are GMT. The time now is 04:07 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.01129 seconds
  • Memory Usage 1,714KB
  • 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_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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