Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Yuna Scatari Edition (YSE) (http://www.bvlist.com/forumdisplay.php?f=22)
-   -   Problem with poll (http://www.bvlist.com/showthread.php?t=5814)

Tmx 17th December 2010 16:02

Problem with poll
 
Hi, i have small problem with poll
I can't vote in poll.... when i vote it not show a result!

and there is my poll.php

Code:

if (!defined('BLOCK_FILE')) {
 Header("Location: ../index.php");
 exit;
}

global $CURUSER, $tracker_lang, $ss_uri;

  // Get current poll
  $res = sql_query("SELECT * FROM polls ORDER BY added DESC LIMIT 1") or sqlerr(__FILE__, __LINE__);
  if($pollok=(mysql_num_rows($res))) {
          $arr = mysql_fetch_assoc($res);
          $pollid = $arr["id"];
          $userid = $CURUSER["id"];
          $question = $arr["question"];
          $o = array($arr["option0"], $arr["option1"], $arr["option2"], $arr["option3"], $arr["option4"],
            $arr["option5"], $arr["option6"], $arr["option7"], $arr["option8"], $arr["option9"],
            $arr["option10"], $arr["option11"], $arr["option12"], $arr["option13"], $arr["option14"],
            $arr["option15"], $arr["option16"], $arr["option17"], $arr["option18"], $arr["option19"]);

  // Check if user has already voted
          $res = sql_query("SELECT * FROM pollanswers WHERE pollid=$pollid AND userid=$userid") or sqlerr(__FILE__, __LINE__);
          $arr2 = mysql_fetch_assoc($res);
  }

  $blocktitle = $tracker_lang['poll'].(get_user_class() >= UC_MODERATOR ? " - [".$tracker_lang['create']."]".($pollok ? " - [Labot] - [Dzēst]" : "")."" : "");

        if($pollok) {
          $content .= ("

$question

\n");
          $voted = $arr2;
          if ($voted) {
            // display results
            if ($arr["selection"])
              $uservote = $arr["selection"];
            else
              $uservote = -1;
                        // we reserve 255 for blank vote.
            $res = sql_query("SELECT selection FROM pollanswers WHERE pollid=$pollid AND selection < 20") or sqlerr(__FILE__, __LINE__);

            $tvotes = mysql_num_rows($res);

            $vs = array(); // array of
            $os = array();

            // Count votes
            while ($arr2 = mysql_fetch_row($res))
              $vs[$arr2[0]] += 1;

            reset($o);
            for ($i = 0; $i < count($o); ++$i)
              if ($o[$i])
                $os[$i] = array($vs[$i], $o[$i]);

            function srt($a,$b) {
              if ($a[0] > $b[0]) return -1;
              if ($a[0] < $b[0]) return 1;
              return 0;
            }

            // now os is an array like this: array(array(123, "Option 1"), array(45, "Option 2"))
            if ($arr["sort"] == "yes")
                usort($os, srt);

            $content .= ("\n");
            $i = 0;
            while ($a = $os[$i]) {
              if ($i == $uservote)
                $a[1] .= " *";
              if ($tvotes == 0)
                      $p = 0;
              else
                      $p = round($a[0] / $tvotes * 100);
              if ($i % 2)
                $c = "";
              else
                $c = " bgcolor=\"#eeeeee\"";
              $content .= ("\n");
              ++$i;
            }
            $content .= ("
" . $a[1] . "  " .
                "                 "\"> $p%
\n");
            $tvotes = number_format($tvotes);
            $content .= ("

Votes: $tvotes

\n");
          } else {
            $content .= ("
\n");
            $i = 0;
            while ($a = $o[$i]) {
              $content .= ("$a\n");
              ++$i;
            }
            $content .= ("");
            $content .= ("".$tracker_lang['blank_vote']."\n");
            $content .= ("

");
            $content .= ("
");
          }
        if ($voted)
          $content .= ("\n");
        } else {
            $content .= "
";
            $content .= "

".$tracker_lang['no_polls']."

\n";
            $content .= "
";
        }
?>


mat22 17th December 2010 20:01

I have same problem. Everything worked fine before i turned on blocks system. But it works fine on clean source without my modding. Where's problem?


All times are GMT +2. The time now is 21:23.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.