PHP - I cannot update my database
<p>Can anyone help me?</p>

<p>It seems I cannot update my database using this code I made.</p>

<p>I dont know wats wrong.</p>

<p>I want to update the entire row of a specified ID while displaying the old data in a form.</p>

<p>How do I correct this?</p>

<pre><code>&lt;?php //upd_emp.php

  mysql_connect ("localhost", "root","")  or die (mysql_error());
  mysql_select_db ("emp_db0");
  $id =$_POST['emp_idn'];

  $result = mysql_query("SELECT * FROM emp_tbl WHERE emp_id  = '$id'");
  $test = mysql_fetch_array($result);
  if (!$result) 
    {
    die("Error: Data not found..");
    }
            $fname=$test['fname'] ;
            $mname= $test['mname'] ;                    
            $lname=$test['lname'] ;
            $email=$test['email'] ;

     if(isset($_POST['SAVE']))
     {  
 $f_save = $_POST['f_name'];
 $m_save = $_POST['m_name'];
 $l_save = $_POST['l_name'];
 $e_save = $_POST['e_mail'];

mysql_query("UPDATE emp_tbl SET fname ='$f_save', mname ='$m_save',
     lname ='$l_save',email ='$e_save' WHERE emp_id = '$id'")
            or die(mysql_error()); 
echo "Saved!";


     }

    ?&gt;

    &lt;form action = "upd_emp.php" method="post"&gt;

            First Name:&lt;input type="text" name="f_name" value="&lt;?php echo $fname ?&gt;"/&gt;
            Middle Initial:&lt;input type="text" name="m_name" value="&lt;?php echo $mname ?&gt;"/&gt;
            Last Name:&lt;td&gt;&lt;input type="text" name="l_name" value="&lt;?php echo $lname ?&gt;"/&gt;
            Email Add:&lt;input type="text" name="e_mail" value="&lt;?php echo $email ?&gt;"/&gt;
            &lt;input type="submit" name="save" value="SAVE" /&gt;

     &lt;/form&gt;



This code here at top came from a form page after clicking the submit button "view.php"
   &lt;?php $id =$_POST['emp_idn']; ?&gt;
</code></pre>
