Jump to content

[SOLVED] edit field doesn't update weird


jeff5656

Recommended Posts

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...

Link to comment
https://forums.phpfreaks.com/topic/138225-solved-edit-field-doesnt-update-weird/
Share on other sites

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.