Jump to content

[SOLVED] Can't update the table


jeff5656

Recommended Posts

Here is part of my form. 

<input name="which_month" type="text" size="20" value="<?php echo $row['which_month']; ?>" />

 

But when I run the action script (see below) I get "Unknown column 'November' in 'where clause'

(November is the posted variable in this example)

 

include "../connectdb.php";
$this_month=$_POST['which_month'];
$query = "UPDATE staffsched SET ";
$set = array();
foreach($_POST as $field => $value){
    $field = mysql_real_escape_string($field);
    $value = mysql_real_escape_string($value);
    $set[] = "`{$field}` = '{$value}'";


}


$query .= implode(", ",$set) . "WHERE which_month = $this_month";
mysql_query($query) or die(mysql_error());

Link to comment
https://forums.phpfreaks.com/topic/133577-solved-cant-update-the-table/
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.