I am new to using PDO and I have no clue what is wrong with it. It says i have this error
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING on line 3 Here is my code that goes along with it.
<?php
include 'dbconnect.php';
$sql = "INSERT INTO event (name,location,admission,map,additional,featured,description) VALUES (:name,:location,:admission,:map,:additional,:featured,:description)";
$q = $conn->prepare($sql);
$q->execute(array(':name'=>$_POST['name'],
':location'=>$_POST['location'],
':admission'=>$_POST['addmission'],
':map'=>$_POST['map'],
':additional'=>$_POST['additional'],
':featured'=>$_POST['featured'],
':description'=>$_POST['description']));
?>
Remove the double quotes from all of these
$_POSTvariables. There is no need to quote them, and indeed it causes harm if you also quote their array keys.Inside a double-quoted string, if referencing array keys, you must not quote the keys, or surround the whole thing in
{}. But neither is necessary here.In fact, there is no real need to assign them to variables at all. Just use the
$_POSTinputs directly in theexecute()call.