title: Edit MYSQL Row in PHP form
body: <p>I have done this before and for some reason I just can't get it to work this time!
  I'm pulling my hair out over this! Because there is no errors, it just wont update the database.</p>
  
  <p>Basically I Have a Table with student data in....</p>
  
  <p>ID | IMGNU | Firstname  |  Surname  | FBID</p>
  
  <p>Let's use row 233 for an example.</p>
  
  <p>I can view a specific row by going to view.php?ID=233</p>
  
  <p>Then that works, but now i want to be able to go to edit.php?ID=233
  and it should load a form, that already has the info from row 233.
  I should then be able to edit the data in the fields and submit the form,
  which would change the information in the database.</p>
  
  <p>Here is what i have already.</p>
  
  <p><strong>edit.php</strong></p>
  
  <pre><code>&lt;?php
  mysql_connect('localhost', 'admin', 'passw0rd') or die(mysql_error());
  echo "Tick &lt;p&gt;";
  mysql_select_db("students") or die(mysql_error());
  echo "Tick"; 
  
  $UID = $_GET['ID'];
  
  $query = mysql_query("SELECT * FROM stokesley_students WHERE id = '$UID'")
  or die(mysql_error());  
  
  while($row = mysql_fetch_array($query)) {
  echo "";
  
  $firstname = $row['firstname'];
  $surname = $row['surname'];
  $FBID = $row['FBID'];
  $IMGNU = $row['IMGNU'];
  
  
  };
  
  ?&gt;
  
  &lt;form action="update.php?ID=&lt;?php echo "$UID" ?&gt;" method="post"&gt;
  
  IMGNU: &lt;input type="text" name="ud_img" value="&lt;?php echo "$IMGNU" ?&gt;"&gt;&lt;br&gt;
  
  First Name: &lt;input type="text" name="ud_firstname" value="&lt;?php echo "$firstname" ?&gt;"&gt;&lt;br&gt;
  
  Last Name: &lt;input type="text" name="ud_surname" value="&lt;?php echo "$surname" ?&gt;"&gt;&lt;br&gt;
  
  FB: &lt;input type="text" name="ud_FBID" value="&lt;?php echo "$FBID" ?&gt;"&gt;&lt;br&gt;
  
  &lt;input type="Submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>And here is update.php</strong></p>
  
  <pre><code>&lt;
  
  ?php
  
  $ud_ID = $_GET["ID"];
  
  $ud_firstname = $_POST["ud_firstname"];
  $ud_surname = $_POST["ud_surname"];
  $ud_FBID = $_POST["ud_FBID"];
  $ud_IMG = $_POST["ud_IMG"];
  
  mysql_connect('localhost', 'admin', 'passw0rd') or die(mysql_error());
  echo "MySQL Connection Established! &lt;br&gt;";
  
  mysql_select_db("students") or die(mysql_error());
  echo "Database Found! &lt;br&gt;";
  
  
  $query="UPDATE * stokesley_students SET firstname = '$ud_firstname', surname = '$ud_surname', 
  FBID = '$ud_FBID' WHERE ID ='$ud_IMG'";
  
  mysql_query($query);
  
  echo "&lt;p&gt;Record Updated&lt;p&gt;";
  
  mysql_close();
  ?&gt;
  </code></pre>
  
  <p>Any ideas would be much appreciated, maby im just missing something stupid?</p>
  
  <p>Thanks 
  Alex</p>