0

Hello,

i am trying to update a table row from a form the code is:

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="votim" id="votim">
	    <p>
	      <input type="hidden" name="email" id="email"  value="<?php echo $usernamepervotime ?>"/>
          <input type="hidden" name="vota" id="vota"  value="<?php htmlentities($row_VotaMiss['vota']+1); ?>"/>
          <input type="hidden" name="ID" id="ID"  value="<?php echo $row_VotaMiss['ID']; ?>"/>
        </p>
	    <p>&nbsp;</p>

	    <p><a href="#" onclick="document['votim'].submit()">Voto</a></p>
        
<?php 
if(isset($_POST['email'])){
$email = $_REQUEST['email'];
$vota = $_POST['vota'];
$id = $_POST['ID'];
$update = mysql_query("UPDATE table SET vota=$vota WHERE ID=$id");
	 }
?>
        </form>

but it wont work... can anyone help me??? the row table has 11 columns and the column i want to update is the last one named "vota"

thank you in advance
NiKu

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by nileshgr
0

Echo all the variables you have and ensure you received values before using update

$update = mysql_query("UPDATE table SET vota='$vota' WHERE ID='$id'");

Also try with the single quotes like above.

if (mysql_num_rows($update) > 0) { 
echo "rows affected";
} else echo "rows doesnot affected";

Also add the above statements and check whether it affected the rows or not.

0

@raja, Even I had thought he needed quotes, but no; quotes are not required for numeric fields. That's why I asked him to dump $_POST.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.