Hi,
I'm pretty new to php and MySQL.
I am trying to use a form to update a the database. However it just doesn't seem to actually work.
I also am getting this error from printing out errors:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INT1 = '', INT2 = '', INT3 = '', INT4 = '' at line 1
Here is my code that I am using to update the database from the form.
All the capital stuff (eg. FF, FPL, FFL) is the name and the id of the <input>'s in the form.
Have I done this correct?
// if form has been submitted, update record
if (array_key_exists('publish', $_POST)) {
$team = $_GET['team'];
// prepare update query
$sql = "UPDATE team SET FF = ?, FPL = ?, FPR = ?, FFL = ?, CHF = ?, FFR = ?, WL = ?, C = ?, WR = ?, BFL = ?, CHB = ?, BFR = ?, BPL = ?, BPR = ?, FB = ?, RUCK = ?, RR = ?, ROVER = ?, INT1 = ?, INT2 = ?, INT3 = ?, INT4 = ?, INT5 = ?, INT6 = ?, EMG1 = ?, EMG2 = ?, EMG3 = ?, EMG4 = ?, EMG5 = ?, EMG6 = ?, COACH = ?, CAP = ?, VCAP = ? WHERE team = '".$team."'";
$update = $conn->prepare($sql);
// execute query by passing array of variables
$done = $update->execute(array($_POST['FF'], $_POST['FPL'], $_POST['FPR'], $_POST['FFL'], $_POST['CHF'], $_POST['FFR'], $_POST['WL'], $_POST['C'], $_POST['WR'], $_POST['BFL'], $_POST['CHB'], $_POST['BFR'], $_POST['BPL'], $_POST['BPR'], $_POST['FB'], $_POST['RUCK'], $_POST['RR'], $_POST['ROVER'], $_POST['INT1'], $_POST['INT2'], $_POST['INT3'], $_POST['INT4'], $_POST['INT5'], $_POST['INT6'], $_POST['EMG1'], $_POST['EMG2'], $_POST['EMG3'], $_POST['EMG4'], $_POST['EMG5'], $_POST['EMG6'], $_POST['COACH'], $_POST['CAP'], $_POST['VCAP']));
echo "$sql"; //this is here so I can see whats getting sent.
}
Am I supposed to put the $_POST, where the ? are in the sql statement? or put them in a variable then add that in instead of the ? ?
Thanks for your help.
Cheers,
QWaz