jeff5656 Posted December 23, 2008 Share Posted December 23, 2008 When a user edits this form, all the fields get correctly updated except patient. I also notice that a ' character gives me a syntax error even though I used mysql_real_escape_string! That suggests something is fishy. <a href = "displayactive.php">[RETURN TO ROUNDING LIST]</a> <form action="commit.php"?action=<?php echo $_GET['action']; ?>&type=icu&id=<?php echo $_GET['id']; ?>" method="post"> <table width="95%" border="0"> <tr> <th scope="col">Patient Name<span class="style1">*</span></th> etc. </tr> <tr> <td><input name="patient" type="text" size="20" value="<?php echo $patient; ?>" /></td> commit.php: $query = "SELECT * FROM `icu` WHERE `patient` = '".$_POST['patient']."' "; $result = mysql_fetch_array(mysql_query($query)) or die(mysql_error()); $problist = $result['problist']; if($problist != $_POST[problist]) { $problist_date = date("Y-m-d H:i:s"); } else { $problist_date = $result['problist_date']; } $todo = $result['todo']; if($todo != $_POST[todo]) { $todo_date = date("Y-m-d H:i:s"); } else { $todo_date = $result['todo_date']; } $sql = "UPDATE icu SET rm_loc = '" . mysql_real_escape_string($_POST['rm_loc']) . "', patient = '" . mysql_real_escape_string($_POST['patient']) . "', mrn = '" . mysql_real_escape_string($_POST['mrn']) . "', etc Could the initial query in the beginning of commit.php be the problem since I used the _POST[patient] in the WHERE? That's the only thing I can think of... Quote Link to comment https://forums.phpfreaks.com/topic/138225-solved-edit-field-doesnt-update-weird/ Share on other sites More sharing options...
revraz Posted December 23, 2008 Share Posted December 23, 2008 Have you tried echo'g $sql and putting mysql_error() after your query? Quote Link to comment https://forums.phpfreaks.com/topic/138225-solved-edit-field-doesnt-update-weird/#findComment-722656 Share on other sites More sharing options...
jeff5656 Posted December 23, 2008 Author Share Posted December 23, 2008 The problem was the WHERE POST patient. I changed it to id_incr and it works. Porbably means there were more than 2 records with the same name so Iused a unique field and it works now. Quote Link to comment https://forums.phpfreaks.com/topic/138225-solved-edit-field-doesnt-update-weird/#findComment-722664 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.