jeff5656 Posted November 21, 2008 Share Posted November 21, 2008 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()); Quote Link to comment Share on other sites More sharing options...
marcus Posted November 21, 2008 Share Posted November 21, 2008 We established this previously. $query .= implode(", ",$set) . " WHERE `which_month` = '".$this_month."'"; Quote Link to comment Share on other sites More sharing options...
gevans Posted November 21, 2008 Share Posted November 21, 2008 $query .= implode(", ",$set)." WHERE which_month='$this_month'"; Quote Link to comment 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.