Not sure what my problem is. On line 4 I keep getting an error.
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING
Im assuming its not line 4 but could be. Am I missing something or did I just goof?
$id = $_GET['id'];
$query = "UPDATE todo_item2
SET todo = $_POST['i'],
percent = $_POST['p'],
due_date = $date
WHERE todo_id = :id";
$query2 = "UPDATE todo_category2
SET category = $_POST['c']
WHERE todo_id = :id";
$id = $_GET['id'];
$statement1 = $db->prepare($query);
$statement1 -> execute(array(
'id' =>$id,
));
$statement2 = $db->prepare($query2);
$statement2 -> execute(array(
'id' =>$id,
));
Array elements with quoted keys need to use the curly syntax to parse correctly: http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing
The following code should work:
Anyway, considering security, it is a terrible idea to use
$_POSTarray elements directly inside your SQL query!