Jump to content

[SOLVED] Im Having Trouble Fining The Error In My Code


JLitkie

Recommended Posts

Im qorking on a information storage program that will print out medical forms an store them in a database.  I am currently on the page that you can access a previous medical form and update the form.  I have an error in the code and I cant seem to locate it.  The error message says that I have an eror in my syntax..  I can seem to find it.  I always have trouble with the update part of coding, not sure why.  If any one could help I would appreciate it.  The program is for my military unit, so it would be a big help and I gotta finish the whole program by the end of the week.

 

Here is the Code

 

<?php

  $LastName = $_POST['Last_Name'];
  $DOB = $_POST['DOB'];
  $SSN = $_POST['SSN'];
  $TDate = $_POST['Date'];
  $FirstName = $_POST['First_Name'];
  $Gender = $_POST['Gender'];
  $RankGrade = $_POST['Rank_Grade'];
  $Unit = $_POST['Unit'];
  $Time = $_POST['Time'];

  $host = "localhost";
  $user = "root";
  $password = "";
  $dbname = "Medical";

  $cxn = mysqli_connect($host,$user,$password,$dbname)
  	      or die ("Couldn't connect to server");

  $good_data = $_POST;
  
  foreach($good_data as $field => $value)
  {
    if($field != "submitted")
{
   $field_array[] = $field;
   $clean = strip_tags(trim($value));
   $escaped = mysqli_real_escape_string($cxn,$clean);
   $value_array[] = $escaped;
}
  }
  
  $fields = implode(",",$field_array);
  $values = implode('","',$value_array);
  $sql = "UPDATE SF600T01 Last_Name = '$LastName' First_Name = '$FirstName' DOB = '$DOB' Gender = '$Gender' Rank_Grade = '$RankGrade' SSN = '$SSN' Unit = '$Unit' Date = '$TDate' Time = '$Time' WHERE Last_Name='$LastName' AND DOB='$DOB' AND SSN='$SSN' AND Date='$TDate'";
  
  $result = mysqli_query($cxn,$sql)
  		  or die("Couldn't execute query: ".mysqli_error($cxn));
	  
  include('FM600B02.php');
  
  echo "<font size='3' face='Arial, Bookman Old Style, Georgia' style='position:absolute;right:5%;top:10%;'><center><b>Patient<br>Information<br>Saved</font>";

?>

 

Thanks Everyone,

 

PFC Litkie

US ARMY

$sql = "UPDATE SF600T01 Last_Name = '$LastName', First_Name = '$FirstName', DOB = '$DOB', Gender = '$Gender', Rank_Grade = '$RankGrade', SSN = '$SSN', Unit = '$Unit', Date = '$TDate', Time = '$Time' WHERE Last_Name='$LastName' AND DOB='$DOB' AND SSN='$SSN' AND Date='$TDate'";
  

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.