I am getting this error message on an assignment for class. Ive created an UPDATE which uses forms for a user to edit the content being printed out from a database on the previous page.
I am getting Invalid parameter number: number of bound variables does not match number of tokens on line 14
<?
require '../connection.php';
if (isset($_POST['save'])) {
$sql = "UPDATE videoinfo
SET submitter = :submitter,
videoTitle = :videoTitle,
channelName = :channelName,
videoLink = :videoLink
WHERE videoId = :videoId";
$stmt = $dataconn -> prepare($sql);
$stmt -> execute( array(":submitter" => $_POST['submitter'],
":videoTitle" => $_POST['videoTitle'],
":channelName" => $_POST['channelName'],
":videoLink" => $_POST['videoLink']) );
echo "Record Updated";
echo "<br />";
include 'adminmain.php';
} else {
$sql = "SELECT *
FROM videoinfo AS v
WHERE videoId = :videoId";
$stmt = $dataconn -> prepare($sql);
$stmt -> execute( array(":videoId" => $_POST['videoId']) );
$video = $stmt->fetch();
}?>
<html>
<?
if (isset($_POST['update'])) {
?>
<form method="post">
Submitter: <input type="text" name="submitter" value="<?= $video['submitter'] ?>" /> <br />
Video Title: <input type="text" name="videoTitle" value="<?= $video['videoTitle'] ?>" /> <br />
Channel Name: <input type="text" name="channelName" value="<?= $video['channelName'] ?>" /> <br />
Video Link: <input type="text" name="videoLink" value="<?= $video['videoLink'] ?>" /> <br />
<input type="hidden" name="videoId" value="<?= $video['videoId'] ?>" />
<input type="submit" value="Save" name="save" />
</form>
<?
}//endIf
?>
</html>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…