JLitkie Posted January 14, 2009 Share Posted January 14, 2009 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 Link to comment https://forums.phpfreaks.com/topic/140778-solved-im-having-trouble-fining-the-error-in-my-code/ Share on other sites More sharing options...
trq Posted January 14, 2009 Share Posted January 14, 2009 $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'"; Link to comment https://forums.phpfreaks.com/topic/140778-solved-im-having-trouble-fining-the-error-in-my-code/#findComment-736828 Share on other sites More sharing options...
JLitkie Posted January 14, 2009 Author Share Posted January 14, 2009 Thanks, I had just realized from reading another post that I forgot the commas between the entries. Thanks again bud. Link to comment https://forums.phpfreaks.com/topic/140778-solved-im-having-trouble-fining-the-error-in-my-code/#findComment-736850 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.