I am extremely new to PHP. I’d like to use prepared PDO statements, but mine isn’t working. I tried to follow a simple example at
Here’s what I have below(and yeah, I know range, range2, and spellrange all refer to the same thing, but I realized I got errors when I called the field in MySQL “range”, so I changed the field to ‘spellrange’ in the database) – I did an echo of the POST stuff sent to the page (echo now removed), and I am getting all the POST information successfully – Here’s the error:
SQLSTATE[42000]: Syntax error or access violation: 1064 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 ') WHERE id='747')' at line 2
The id=747 is correct. That’s the ID I clicked on from the previous page, and it does exist in the database.
Hope I’m not too lame here, but I was trying to follow the example on that web site (which seemed like the simplest one I saw).
<?PHP
// MAIN PROCESSING SECTION
$id = $_POST['id'];
$level = $_POST['level'];
$specialty = $_POST['specialty'];
$name = $_POST['name'];
$cost = $_POST['cost'];
$bcu = $_POST['bcu'];
$range2 = $_POST['range'];
$prereq = $_POST['prereq'];
$description = $_POST['description'];
try {
$sql = "UPDATE tblspells
SET level=?, specialty=?, name=?, cost=?, spellrange=?, basecostuses=?, prereq=?, description=?) WHERE id=?)";
$q = $pdo->prepare($sql);
$q->execute(array($level, $specialty, $name, $cost, $range2, $bcu, $prereq, $description, $id));
}
catch(PDOException $e)
{
echo "Error ---------- " . $e->getMessage();
}
?>
for starter, You have extra closing brackets after
'description'andwhereclause.