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">
	      <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><a href="#" onclick="document['votim'].submit()">Voto</a></p>
$email = $_REQUEST['email'];
$vota = $_POST['vota'];
$id = $_POST['ID'];
$update = mysql_query("UPDATE table SET vota=$vota WHERE ID=$id");

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

Member Avatar


Paste the output of var_dump($_POST) inside the if condition.

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.

Member Avatar


@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.