Dropdown Field set to Update, but MYSQL won't post update

Mysql Portion:

[php]if ($_POST[‘bUpdate’]){

mysql_query(“UPDATE Patients SET b = ‘$_POST[bUpdate]’ WHERE id = '”.$_GET[‘id’]."’");

}[/php]

Form Portion:

[php]<?

if ($data[‘b’] == 1){

echo ‘YesNo’;

} else {

echo ‘YesNo’;

}

?>[/php]

When I echo $_POST[‘bUpdate’]; it yields the correct value when the option is selected in the dropdown.

Change this
[sup]
if ($_POST[‘bUpdate’]){
mysql_query(“UPDATE Patients SET b = ‘$_POST[bUpdate]’ WHERE id = '”.$_GET[‘id’]."’");
}
[/sup]

to this
[sup]
if ($_POST[‘bUpdate’]){
mysql_query(“UPDATE Patients SET b=’{$_POST[bUpdate]}’ WHERE id={$_GET[‘id’]}”);
}
[/sup]

You don’t need quotes around the table name or column names, and when using superglobals such as $_POST or $_GET etc within quotes “” always wrap it in curly braces.
also i notice you use short open tags <? this is not the best way to code, you should use the full <?php so your code will work on any server that has short open tags turned off :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service