I'm struggling to see where the problem is with my syntax, or figure out where said problem is coming from/what needs to be changed. I am getting thrown this error
Fatal error: Uncaught PDOException: 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 stadiumID = 68' at line 5 in /studen in /studenthome.hallam.shu.ac.uk/STUDENTHOME10/4/b6029514/public_html/pdo-cms1/cms/process/editRecord.php on line 24
When running my editRecord.php page. Below is the code for said page.
<?php
ini_set('display_errors', 1);
require('../../../conn.inc.php');
require('../../includes/functions.inc.php');
$sStadiumName = safeString($_POST['stadiumName']);
$sMatchDescription = safeString($_POST['matchDescription']);
$sStadiumImage = safeString($_POST['stadiumImage']);
$sTicketPrice = safeFloat($_POST['ticketPrice']);
$sStadiumID = safeInt($_POST['stadiumID']);
// prepare SQL
$sql = "UPDATE movies SET stadiumName = :stadiumName,
matchDescription = :matchDescription,
stadiumImage = :stadiumImage,
ticketPrice = :ticketPrice,
WHERE stadiumID = :stadiumID";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':stadiumName', $sStadiumName, PDO::PARAM_STR);
$stmt->bindParam(':matchDescription', $sMatchDescription, PDO::PARAM_STR);
$stmt->bindParam(':stadiumImage', $sStadiumImage, PDO::PARAM_STR);
// use PARAM_STR although a number
$stmt->bindParam(':ticketPrice', $sTicketPrice, PDO::PARAM_STR);
$stmt->bindParam(':stadiumID', $sStadiumID, PDO::PARAM_INT);
$stmt->execute();
// redirect browser
header("Location: ../cms.php");
// make sure no other code executed
exit;
?>
Aucun commentaire:
Enregistrer un commentaire