vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   vote modifikation (https://vborg.vbsupport.ru/showthread.php?t=143096)

ragtek 03-25-2007 10:21 AM

vote modifikation
 
i'd like to check if someone is allowed to vote or not and to write the votenumber into a db

my code looks at moment so:

PHP Code:

if ($foruminfo['forumid'] == $vbulletin->options['battleforumid'
         AND !
$check $db->query_first("SELECT postid FROM " TABLE_PREFIX "post WHERE threadid = $threadinfo[threadid]
         AND userid = " 
$vbulletin->userinfo['userid']))
{
  
print_no_permission();
}

else {
    
       
$entry $db->query_first("SELECT answers FROM " .TABLE_PREFIX"battles WHERE threadid = '" .$threadinfo[threadid] . "'"); 
       
$antworten $db->fetch_array($entry);
       if (
$entry['answers'] < $vbulletin->options['maxpolls']){
           
$db->query_write("
            update " 
TABLE_PREFIX "battles set answers = answers +1");
  
}
else  
print_no_permission();



it doesnt update the answers nr :/

nexialys 03-25-2007 10:31 AM

SELECT answers FROM

have to be:

SELECT count(answers) AS counted FROM

and then... if ($entry['counted'] < $vbu

ragtek 03-25-2007 10:35 AM

why?

it should be just one line per poll
so theres no count needed

if someone votes the answernumber should be set to answernumber +1

ktutorials 03-28-2007 12:24 PM

i am not that much good in php... but just seeing through the code its like

if(condition) {

} else {
}
else {
}

when does the 2nd else is called...

sorry if its a poor question...

ragtek 03-28-2007 12:43 PM

oh there coulde be something

thx i'll look at home

no
the if else else is ok

PHP Code:

if ($foruminfo['forumid'] == $vbulletin->options['battleforumid'
         AND !
$check $db->query_first("SELECT postid FROM " TABLE_PREFIX "post WHERE threadid = $threadinfo[threadid]
         AND userid = " 
$vbulletin->userinfo['userid']))
{
  
print_no_permission();

}

else {
    
       
$entry $db->query_first("SELECT answers FROM " .TABLE_PREFIX"battles WHERE threadid = '" .$threadinfo[threadid] . "'"); 
       
$antworten $db->fetch_array($entry);
       if (
$entry['answers'] < $vbulletin->options['maxpolls'])
           {
           
$db->query_write("
            update " 
TABLE_PREFIX "battles set answers = answers +1");
            }
       else 
print_no_permission();



omg
all the code is shit

Mythotical 03-30-2007 07:55 PM

man you need to use $vbulletin->db->blah instead of $db->blah

Try changing those to what I gave and see if it works.


All times are GMT. The time now is 01:39 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.01115 seconds
  • Memory Usage 1,734KB
  • 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
  • (6)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