Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-28-2009, 05:29 PM
zeroality zeroality is offline
 
Join Date: Jul 2006
Posts: 187
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default this plugin code makes my forums have a database error

If this is the wrong place for this, please move it to the proper forum, thanks!

I am using this in one forum that has 3.8.2 running and it works great, so I don't know if 3.8.3 is causing the problem.

Code:
$postchars = 250;

 $news1 = $db->query_first('SELECT title,threadid,views,replycount,postusername,postuserid,dateline FROM ' . TABLE_PREFIX . 'thread WHERE 1 AND forumid = 34 ORDER BY dateline DESC  LIMIT 0 , 1');
 $news1_title = "<a href=\"forums/showthread.php?"  . $vbulletin->session->vars['sessionurl'] . "t=$news1[threadid]\">$news1[title]</a>";
 $news1_readmore = "<a href=\"forums/showthread.php?"  . $vbulletin->session->vars['sessionurl'] . "t=$news1[threadid]\">[Read More]</a>";
 $news1_comment = "<a href=\"forums/newreply.php?do=newreply&noquote=1&"  . $vbulletin->session->vars['sessionurl'] . "t=$news1[threadid]\">[Post Comment]</a>";
 $news1_replies = "$news1[replycount]";
 $news1_views = "$news1[views]";
 $news1_post = $db->query_first('SELECT pagetext FROM ' . TABLE_PREFIX . 'post WHERE 1 AND threadid = ' . $news1[threadid] . ' ORDER BY dateline ASC  LIMIT 0 , 1');
 $news1_postfull = "$news1_post[pagetext]";
 $news1_postshort = substr($news1_post[pagetext],0,$postchars);
 $news1_date = vbdate($vbulletin->options['dateformat'], $news1['dateline']);
 $news1_time = vbdate($vbulletin->options['timeformat'], $news1['dateline']);

 $news2 = $db->query_first('SELECT title,threadid,views,replycount,postusername,postuserid,dateline FROM ' . TABLE_PREFIX . 'thread WHERE 1 AND forumid = 34 ORDER BY dateline DESC  LIMIT 1 , 1');
 $news2_title = "<a href=\"forums/showthread.php?"  . $vbulletin->session->vars['sessionurl'] . "t=$news2[threadid]\">$news2[title]</a>";
 $news2_readmore = "<a href=\"forums/showthread.php?"  . $vbulletin->session->vars['sessionurl'] . "t=$news2[threadid]\">[Read More]</a>";
 $news2_comment = "<a href=\"forums/newreply.php?do=newreply&noquote=1&"  . $vbulletin->session->vars['sessionurl'] . "t=$news2[threadid]\">[Post Comment]</a>";
 $news2_replies = "$news2[replycount]";
 $news2_views = "$news2[views]";
 $news2_post = $db->query_first('SELECT pagetext FROM ' . TABLE_PREFIX . 'post WHERE 1 AND threadid = ' . $news2[threadid] . ' ORDER BY dateline ASC  LIMIT 0 , 1');
 $news2_postfull = "$news2_post[pagetext]";
 $news2_postshort = substr($news2_post[pagetext],0,$postchars);
 $news2_date = vbdate($vbulletin->options['dateformat'], $news2['dateline']);
 $news2_time = vbdate($vbulletin->options['timeformat'], $news2['dateline']);

 $news3 = $db->query_first('SELECT title,threadid,views,replycount,postusername,postuserid,dateline FROM ' . TABLE_PREFIX . 'thread WHERE 1 AND forumid = 34 ORDER BY dateline DESC  LIMIT 2 , 1');
 $news3_title = "<a href=\"forums/showthread.php?"  . $vbulletin->session->vars['sessionurl'] . "t=$news3[threadid]\">$news3[title]</a>";
 $news3_readmore = "<a href=\"forums/showthread.php?"  . $vbulletin->session->vars['sessionurl'] . "t=$news3[threadid]\">[Read More]</a>";
 $news3_comment = "<a href=\"forums/newreply.php?do=newreply&noquote=1&"  . $vbulletin->session->vars['sessionurl'] . "t=$news3[threadid]\">[Post Comment]</a>";
 $news3_replies = "$news3[replycount]";
 $news3_views = "$news3[views]";
 $news3_post = $db->query_first('SELECT pagetext FROM ' . TABLE_PREFIX . 'post WHERE 1 AND threadid = ' . $news3[threadid] . ' ORDER BY dateline ASC  LIMIT 0 , 1');
 $news3_postfull = "$news3_post[pagetext]";
 $news3_postshort = substr($news3_post[pagetext],0,$postchars);
 $news3_date = vbdate($vbulletin->options['dateformat'], $news3['dateline']);
 $news3_time = vbdate($vbulletin->options['timeformat'], $news3['dateline']);
The error is:

Quote:
Database error in vBulletin 3.8.3:

Invalid SQL:
SELECT pagetext FROM post WHERE 1 AND threadid = ORDER BY dateline ASC LIMIT 0 , 1;

MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY dateline ASC LIMIT 0 , 1' at line 1
Error Number : 1064
Request Date : Sunday, June 28th 2009 @ 06:17:44 PM
Error Date : Sunday, June 28th 2009 @ 06:17:44 PM
Script : http://www.pkmndex.com/forums/index.php
Referrer : http://www.pkmndex.com/forums/forumdisplay.php?f=2
IP Address : 76.198.252.244
Username : zeroality
Classname : vB_Database
MySQL Version : 5.0.81-community
Reply With Quote
  #2  
Old 06-28-2009, 05:37 PM
Cryo Cryo is offline
 
Join Date: Dec 2003
Location: Buffalo, NY
Posts: 197
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

From your error...

$news3_post = $db->query_first('SELECT pagetext FROM ' . TABLE_PREFIX . 'post WHERE 1 AND threadid = ' . $news3[threadid] . ' ORDER BY dateline ASC LIMIT 0 , 1');

The $news3[threadid] variable is returning nothing. Check the query for $news3 and make sure everything is valid. I ran that exact query on my database and it worked fine... unless there are no posts in that forum.
Reply With Quote
  #3  
Old 06-28-2009, 06:00 PM
zeroality zeroality is offline
 
Join Date: Jul 2006
Posts: 187
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oooh that's it. There are no posts yet, only one thread so far heh. Thanks man.
Reply With Quote
  #4  
Old 06-28-2009, 06:03 PM
Cryo Cryo is offline
 
Join Date: Dec 2003
Location: Buffalo, NY
Posts: 197
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No problem. You can also add something like this to fix that problem...

PHP Code:
 $news3 $db->query_first('SELECT title,threadid,views,replycount,postusername,postuserid,dateline FROM ' TABLE_PREFIX 'thread WHERE 1 AND forumid = 34 ORDER BY dateline DESC  LIMIT 2 , 1');
 if (
mysql_num_rows($news3) != 0) {
     
$news3_title "<a href=\"forums/showthread.php?"  $vbulletin->session->vars['sessionurl'] . "t=$news3[threadid]\">$news3[title]</a>";
     
$news3_readmore "<a href=\"forums/showthread.php?"  $vbulletin->session->vars['sessionurl'] . "t=$news3[threadid]\">[Read More]</a>";
     
$news3_comment "<a href=\"forums/newreply.php?do=newreply&noquote=1&"  $vbulletin->session->vars['sessionurl'] . "t=$news3[threadid]\">[Post Comment]</a>";
     
$news3_replies "$news3[replycount]";
     
$news3_views "$news3[views]";
     
$news3_post $db->query_first('SELECT pagetext FROM ' TABLE_PREFIX 'post WHERE 1 AND threadid = ' $news3[threadid] . ' ORDER BY dateline ASC  LIMIT 0 , 1');
     
$news3_postfull "$news3_post[pagetext]";
     
$news3_postshort substr($news3_post[pagetext],0,$postchars);
     
$news3_date vbdate($vbulletin->options['dateformat'], $news3['dateline']);
     
$news3_time vbdate($vbulletin->options['timeformat'], $news3['dateline']);
 } else { echo 
"No news is good news?"; } 
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 09:27 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.03834 seconds
  • Memory Usage 2,211KB
  • 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
  • (1)bbcode_code
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)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