通过接口将数据插入数据库但我收到错误:
警告:PDOStatement :: execute():SQLSTATE [HY093]:参数号无效:参数未在... filetext中定义
我该如何解决这个问题?这是什么意思,这是我THIS
部分担心的所有代码:
<?php
session_start();
if (isset($_GET['map'])){
$map = $_GET['map'];
}
if (isset($_GET['task'])){
$task = $_GET['task'];
}
include("../inc/header.php");
include("../inc/bookshelf.php");
if (isset($_SESSION['logged_in'])){
//display lb page
include("../inc/adminsidebar.html");?>
<?php
if ($task=="insert"){
if ($map == "nacht"){ $mapname = "Nacht Der Untoten - Rounds Survived";
if (isset($_POST['rank'], $_POST['username'], $_POST['rounds'], $_POST['players'], $_POST['lastroundtime'], $_POST['system'], $_POST['reference'])){
$rank = $_POST['rank'];
$username = $_POST['username'];
$rounds = $_POST['rounds'];
$players = $_POST['players'];
$lastroundtime = $_POST['lastroundtime'];
$system = $_POST['system'];
$reference = $_POST['reference'];
if (empty($rank) or empty($username) or empty($rounds) or empty($players) or empty($lastroundtime) or empty($system) or empty($reference)){
$error = "You cannot leave any boxes blank.";
}else{
$query = $pdo->prepare('INSERT INTO leaderboards (rank, username, rounds, players, last_round_time, system, verified, game_id, mode_id, map_id) VALUES (:rank, :username, :rounds, :players, :last_round_time, :system, :reference, 3, 1, 8)');
$query->bindValue(':rank', $rank, PDO::PARAM_INT);
$query->bindValue(':username', $username, PDO::PARAM_STR);
$query->bindValue(':rounds', $rounds, PDO::PARAM_INT);
$query->bindValue(':players', $players, PDO::PARAM_INT);
$query->bindValue(':lastroundtime', $lastroundtime, PDO::PARAM_INT);
$query->bindValue(':system', $system, PDO::PARAM_STR);
$query->bindValue(':reference', $reference, PDO::PARAM_STR);
$query->execute();
$error = "Leaderboard injection successfull";
}
}
print"<h2>You are inserting into <strong>$mapname</strong></h2><br><br>"; ?>
<h4><strong>WARNNING:</strong> Please make sure you delete any data that is going to replace it first before inserting new one.
<small>For example: Dont make a new person rank 5 if you have already got someone as rank 5.</small></h4><br>
<?php
if (isset($error)){
print"<h2 style=\"color:black;\">$error</h2>";
print"<br />";
} ?>
<form action="lbpanelwawmap.php?task=insert&map=nacht" method="post">
<h4>Rank</h4><br>
<input type="text" name="rank" placeholder="Enter the persons rank on the leaderboards" style="width:350px;"/><br><br>
<h4>Username</h4><br>
<input type="text" name="username" placeholder="Their online name, eg: Xbox gamertag" style="width:350px;"/><br><br>
<h4>Rounds</h4><br>
<input type="text" name="rounds" placeholder="How many rounds did the survive?" style="width:350px;"/><br><br>
<h4>Players</h4><br>
<input type="text" name="players" placeholder="Number of players in the game" style="width:350px;"/><br><br>
<h4>Last Round Time</h4><br>
<input type="text" name="lastroundtime" placeholder="How long their last round took" style="width:350px;"/><br><br>
<h4>System</h4><br>
<input type="text" name="system" placeholder="What platform are they playing on?" style="width:350px;"/><br><br>
<h4>Reference</h4><br>
<input type="text" name="reference" placeholder="Youtube video link goes here" style="width:350px;"/><br><br>
<input type="submit" value="Submit" style="width:100px;height:50px;"/> <br>
</form>
<?php
}
答案 0 :(得分:2)
在准备好的陈述中指定:lastroundtime
时,您正在绑定:last_round_time
。
错误告诉您没有绑定预准备语句中包含的所有参数。