1
忍着我發現有很多關於這個錯誤的帖子。但我已經通過他們看了,似乎無法找到解決我的特定問題。警告:mysqli_stmt :: bind_param()變量的數量與預準備語句中的參數數量不匹配
我試過「isi」,「sss」和「sii」不起作用。不知道要做什麼幫助會很好。
不太確定在哪裏使用var_dump();瞭解更多關於我的問題的信息。我對PHP非常陌生,知道這也會有很大的幫助。
感謝您的支持!對於重複的話題感到抱歉。
代碼:
<tr>
<form action="Voting_action.php" method="post">
<td><br />
<input type="submit" class="buttontable1" value="<?php echo $random; ?>" name="name"/>
</td>
</form>
<form action="Voting_action.php" method="post">
<td><br />
<input type="submit" class="buttontable1" value="<?php echo $random3; ?>" name="name"/>
</td>
</form>
</tr>
<tr>
<form action="Voting_action.php" method="post">
<td><br />
<input type="submit" class="buttontable1" value="<?php echo $random6; ?>" name="name"/>
</td>
</form>
<form action="Voting_action.php" method="post">
<td><br />
<input type="submit" class="buttontable1" value="<?php echo $random4; ?>" name="name"/>
</td>
</form>
</tr>
<tr>
<form action="Voting_action.php" method="post">
<td><br />
<input type="submit" class="buttontable1" value="<?php echo $random5; ?>" name="name"/>
</td>
</form>
<form action="Voting_action.php" method="post">
<td><br />
<input type="submit" class="buttontable1" value="<?php echo $random2; ?>" name="name"/>
</td>
</tr>
<?php
include ('login-home.php');
$mysqli = new mysqli("", "", "", "");
if ($mysqli->connect_error) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_error . ") " . $mysqli->connect_error;
}
if (!($stmt = $mysqli->prepare("INSERT INTO table(id, name, votes) VALUES (id, '".$_POST['name']."', '".$votes."')"))) {
echo "Prepare failed: (" . $mysqli->error . ") " . $mysqli->error;
}
$id = 1;
這條線:
if (!$stmt->bind_param("isi",$id, $_POST['name'], $votes)) {
echo "Binding parameters failed: (" . $stmt->error . ") " . $stmt->error;
}
if (!$stmt->execute()) {
echo "Execute failed: (" . $stmt->error . ") " . $stmt->error;
}
$stmt->close();
?>
謝謝你工作得很好! – vince 2013-04-06 23:32:59