problem with poll and mysql

So I voted in the poll I made but the results haven’t changed, so…

The problem is either with the database, which does not receive the data I gave him;
or I just didn’t present the results correctly, so that the poll results are shown to the user as null (0) every time.

Here’s the code:

poll.php
[php]

<?php include("login.php"); echo "

POLL

"; echo ""; echo "

Which browser are you using?

"; echo " Internet Explorer
"; echo " Mozilla Firefox
"; echo " Google Chrome
"; echo ""; echo "see results"; echo ""; ?>

[/php]

results.php
[php]

<?php include("login.php"); function cookie_check() { if (isset($_COOKIE['username']) AND isset($_COOKIE['password'])) return true; elseif (!$_COOKIE['username']) return false; } if (!cookie_check()) echo "You must be logged in to vote in this poll!"; elseif (cookie_check() AND isset($_POST['submit_poll']) AND !isset($_COOKIE['voted'])) { if ($_POST['a']) $vote = 'a'; elseif ($_POST['b']) $vote = 'b'; elseif($_POST['c']) $vote = 'c'; $result = mysql_query ("SELECT `" . '$vote' . "` FROM poll_table"); $row = mysql_fetch_row($result); if ($row[0]) $row[0] = $row[0]++; else $row[0] = 1; mysql_query ("UPDATE poll_table SET" . $vote . "='{$arr[0]}' "); $user = $_COOKIE['username']; setcookie('voted', '$user', time()+3600); } echo "

POLL RESULTS

"; $queryt = mysql_query ("SELECT * FROM poll_table"); $arr = mysql_fetch_array($queryt); $all = $arr['a'] + $arr['b'] + $arr['c']; if ($all) { $a = $arr['a'] / $all; $b = $arr['b'] / $all; $c = $arr['c'] / $all; } else { $a = 0; $b = 0; $c = 0; } echo "Internet Explorer: " . $a . "%
"; echo "Mozilla Firefox: " . $b . "%
"; echo "Google Chrome: " . $c . "%
"; ?>

[/php]
Help me :frowning: Tell me what’s wrong with my code… I am novice at this…

Can anybody answer me?

Hello,

This thread has been locked due to another duplicate thread of this nature that has been answered here: http://www.phphelp.com/forum/index.php?topic=17277.0.

Cheers!

Sponsor our Newsletter | Privacy Policy | Terms of Service