anthonyr
Oct 2nd 2008, 1:44 pm
Well as i'm trying to create a PHP Voting Poll Script, some errors occurred... I was able to rectify some... but one is really killing me:S:S i created a while($fetch= mysql_fetch_array($query)){...}... but the problem is that the things written in the {...} area couldnt be seen:S here's the code...
<?include('connect.php')?>
<?php
$submit= $_POST['submit'];
$id = $_POST['id'];
include('admin/config.php');
$choice = $_POST['choice'];
$ip = $_SERVER['REMOTE_ADDR'];
"<form method='post' action=".$_SERVER['PHP_SELF']." >
<input type='hidden' value=" .$ip."></form>";
?>
<?
if(isset($submit)){
$sql = 'INSERT INTO `warzone`.`recog` (`id`, `ip`, `pollid`) VALUES (NULL, \'' .$ip. '\', \'' .$id. '\');';
$query = mysql_query($sql);
if(!$_POST['choice']){echo "<font color='red'> Please Select an Option </font>";}
if($ip == $fetch['ip']){ echo "You already submitted your vote!";}
else{$sql ='SELECT * FROM `poll` SELECT * FROM `recog ;';
$query = mysql_query($sql);}
while($fetch = mysql_fetch_array($query)){ echo $fetch['question']?>
[HTML]<form method='post' action=<? $_SERVER['PHP_SELF'] ?>" >
<input type='hidden' name='id' value="<? echo $fetch['id'] ?>">
<input type='radio' name='choice' value='1'><? echo $fetch['one'] ?><br/>
<input type='radio' name='choice' value='2'> <? echo $fetch['two']?><br/>
<input type='radio' name='choice' value='3'> <? echo $fetch['three']?><br/>
<input type='radio' name='choice' value='4'><? echo $fetch['four'] ?><br/>
<input type='submit' name='submit' value='Vote!'></form>
<? }
if($choice == 1) $str= "one";
elseif($choice == 2) $str= "two";
elseif($choice == 3) $str= "three";
elseif($choice == 4) $str= "four";
$sql = 'SELECT * FROM `poll`;';
$query = mysql_query($sql);
while($fetche = mysql_fetch_array($query)){
$id = $fetche['id'];}
$sql = 'UPDATE `warzone`.`poll` SET `v '.$str.' = v '.$str.' +1 WHERE `poll`.`id` = \'' .$id.'\' ;';
$query = mysql_query($sql);}}
?>
any help would really be appreciated:D:D
<?include('connect.php')?>
<?php
$submit= $_POST['submit'];
$id = $_POST['id'];
include('admin/config.php');
$choice = $_POST['choice'];
$ip = $_SERVER['REMOTE_ADDR'];
"<form method='post' action=".$_SERVER['PHP_SELF']." >
<input type='hidden' value=" .$ip."></form>";
?>
<?
if(isset($submit)){
$sql = 'INSERT INTO `warzone`.`recog` (`id`, `ip`, `pollid`) VALUES (NULL, \'' .$ip. '\', \'' .$id. '\');';
$query = mysql_query($sql);
if(!$_POST['choice']){echo "<font color='red'> Please Select an Option </font>";}
if($ip == $fetch['ip']){ echo "You already submitted your vote!";}
else{$sql ='SELECT * FROM `poll` SELECT * FROM `recog ;';
$query = mysql_query($sql);}
while($fetch = mysql_fetch_array($query)){ echo $fetch['question']?>
[HTML]<form method='post' action=<? $_SERVER['PHP_SELF'] ?>" >
<input type='hidden' name='id' value="<? echo $fetch['id'] ?>">
<input type='radio' name='choice' value='1'><? echo $fetch['one'] ?><br/>
<input type='radio' name='choice' value='2'> <? echo $fetch['two']?><br/>
<input type='radio' name='choice' value='3'> <? echo $fetch['three']?><br/>
<input type='radio' name='choice' value='4'><? echo $fetch['four'] ?><br/>
<input type='submit' name='submit' value='Vote!'></form>
<? }
if($choice == 1) $str= "one";
elseif($choice == 2) $str= "two";
elseif($choice == 3) $str= "three";
elseif($choice == 4) $str= "four";
$sql = 'SELECT * FROM `poll`;';
$query = mysql_query($sql);
while($fetche = mysql_fetch_array($query)){
$id = $fetche['id'];}
$sql = 'UPDATE `warzone`.`poll` SET `v '.$str.' = v '.$str.' +1 WHERE `poll`.`id` = \'' .$id.'\' ;';
$query = mysql_query($sql);}}
?>
any help would really be appreciated:D:D