updating database with user edit
<p>I am trying to update my database with a post that a user has edited in a forum.  The whole edit form is functioning excet for when they click edit the form submits and goes to the main forum page, but the database and the post doesn't change.</p>

<p>When the submit edit button is pressed I have this:</p>

<pre><code>    &lt;input name="a_id" type="hidden" value="&lt;? echo $rows['a_id']; ?&gt;"&gt;
    &lt;input name="question_id" type="hidden" value="&lt;? echo $rows['question_id']; ?&gt;"&gt;
    &lt;input type="submit" name="Submit" value="edit post"&gt;
</code></pre>

<p>My save edit code is this:</p>

<pre><code> #data preparation for the query 
 $id=intval($_POST['id']);  
 $a_id=intval($_POST['a_id']);
 $question_id=intval($_POST['question_id']);
 foreach ($_POST as $key =&gt; $value) 
 $_POST[$key] = mysql_real_escape_string($value); 


 $sql = "UPDATE $tbl_name SET a_answer='$_POST[a_answer]' WHERE a_id='$a_id' AND question_id='$question_id'";

 if (!mysql_query($sql)) {  
 die('Error: ' . mysql_error()); 
 } 
 mysql_close; 
 header ("location: main_forum.php"); 

 ?&gt;
</code></pre>

<p>Any ideas???</p>

<p><strong>EDIT</strong></p>

<p>For those who find this question useful unlike @mario, the problem was in the variable I was sending to the save edit page.</p>

<pre><code>       &lt;input name="a_id" type="hidden" value="&lt;? echo $rows['a_id']; ?&gt;"&gt;     
&lt;input name="question_id" type="hidden" value="&lt;? echo $rows['question_id']; ?&gt;"&gt;
</code></pre>

<p>Should have been</p>

<pre><code>    &lt;input name="a_id" type="hidden" value="&lt;? echo $a_id; ?&gt;"&gt;     
&lt;input name="question_id" type="hidden" value="&lt;? echo $question_id; ?&gt;"&gt;
</code></pre>
