Jump to content

MySQL Update not working for 1 value, but working with other values


monkeyj

Recommended Posts

When I echo the POST, it echoes the correct value.

The MySQL portion seems to just ignore it all together.

I've tried changing the dropdown option to just a text field, same thing occurred.

I have text fields right above this particular one that update just fine with the SAME exactly scripting.

if POST, update query, done. Works.

 

This one for some reason will not.

 

MySQL portion:

			if ($_POST['bUpdate']){
			mysql_query("UPDATE `Patients` SET `b` = '$_POST[bUpdate]' WHERE `id` = '".$_GET['id']."'");
		}
echo $_POST['bUpdate'];

 

Form Portion:

    <tr onmouseover="color(this, '#baecff');" onmouseout="uncolor(this);">
    <td width="310" colspan="2" align="center"><span class="fontoptions">Postcard Status </span><br />
<?
if ($data['b'] == 1){
	echo '<select name="bUpdate"><option value="1" selected>Yes</option><option value="0">No</option></select>';
} else {
	echo '<select name="bUpdate"><option value="1">Yes</option><option value="0" selected>No</option></select>';
}

?>
</td>
    </tr>

basic debugging: look at the query.

 

$sql = "UPDATE `Patients` SET `b` = '$_POST[bUpdate]' WHERE `id` = '".$_GET['id']."'";
echo "sql: $sql <br />";

 

and check to make sure it doesn't fail.

 

mysql_query($sql) or die(mysql_error());

Figured it out.

It theoretically was supposed to work everytime.

The problem I had was putting it under a if($_POST) because the item will ALWAYS be posted for a radio button.

Regardless, I removed the if($_POST) command and just told it to Update it regardless of any 'change'...

and it detects it just fine.

 

Thanks BlueSky, cause during the debug, I put a line of code OUTSIDE the if command and it changed. :)

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.