Log in

View Full Version : vote modifikation


ragtek
03-25-2007, 10:21 AM
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:


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

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.