title: PHP form to update single MySQL record is not working
body: <p>This is what I usually do at command prompt and it works: </p>
  
  <pre><code>UPDATE saleslog SET Status='Closed' Where FileNumber='142840';
  </code></pre>
  
  <p>The table has about 15 or so columns like ID, FileNumber, Address, Price, Status and more, but I am interested in updating values only in field in the column Status for different records.</p>
  
  <p>What I am trying to make is php form where I can change field in the record always in the same column, but for in different records at different times one at the time, that is to change field in Status column from lets say "Pending" to "Closed"</p>
  
  <p>To be more specific, I want to have form with two fields, where in one I can reference record by <code>FileNumber</code> and the button that when clicked on, would change value in  <code>Status</code> field to "CLOSED".</p>
  
  <pre><code>Before Update
  
  ID   FileNumber   Address         Price   Status
  
  234  142840       123 N Park Ave  235.00  Pending
  
  After Update
  
  ID   FileNumber   Address         Price   Status
  
  234  142840       123 N Park Ave  235.00  Closed
  </code></pre>
  
  <p>I have Googled and found this form somewhere and changed it to my situation. However, every time I click "Update" button, I get error about "unknown column Status". However, if I type something else and click Update, it says "Updated data successfully" but nothing is being updated in the Status field for the record referenced to by typed value in FileNumber column for that particular record.</p>
  
  <p>So, here is the code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;?php
  if(isset($_POST['update']))
  {
  $dbhost = 'localhost';
  $dbuser = 'jack';
  $dbpass = 'somepassword';
  $myDBname = 'mydatabase';
  $conn = mysql_connect($dbhost, $dbuser, $dbpass, $myDBname);
  if(! $conn )
  {
    die('Could not connect: ' . mysql_error());
  }
  
  $FileNumber = $_POST['FileNumber'];
  $Status = $_POST['Status'];
  
  $sql = "UPDATE saleslog ".
         "SET Status = $Status ".
     "WHERE FileNumber = $FileNumber" ;
  
  mysql_select_db('mydatabase');
  $retval = mysql_query( $sql, $conn );
  if(! $retval )
  {
    die('Could not update data: ' . mysql_error());
  }
  echo "Updated data successfully\n";
  mysql_close($conn);
  }
  else
  {
  ?&gt;
  &lt;form method="post" action="&lt;?php $_PHP_SELF ?&gt;"&gt;
  &lt;table width="400" border="0" cellspacing="1" cellpadding="2"&gt;
  &lt;tr&gt;
  &lt;td width="100"&gt;File Number&lt;/td&gt;
  &lt;td&gt;&lt;input name="FileNumber" type="text" id="FileNumber"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td width="100"&gt;Status&lt;/td&gt;
  &lt;td&gt;&lt;input name="Status" type="text" id="Status"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td width="100"&gt; &lt;/td&gt;
  &lt;td&gt; &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td width="100"&gt; &lt;/td&gt;
  &lt;td&gt;
  &lt;input name="update" type="submit" id="update" value="Update"&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  &lt;?php
  }
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;    
  </code></pre>