简体   繁体   English

警告:mysqli_stmt :: bind_param()变量数与准备好的语句中的参数数不匹配

[英]Warning: mysqli_stmt::bind_param() Number of variables doesn't match number of parameters in prepared statement

Bear with me I realize there are many posts about this error. 忍受我,我知道有很多关于此错误的文章。 But I have looked through them and can't seem to find the solution for my particular problem. 但是我已经仔细检查了它们,但似乎找不到我特定问题的解决方案。

I have tried "isi", "sss", and "sii" doesn't work. 我尝试了“ isi”,“ sss”和“ sii”不起作用。 Not sure what to do any help would be great. 不知道该怎么做会很好。

Not too sure where to use var_dump(); 不太确定在哪里使用var_dump(); to find out more information about my problem. 找出有关我的问题的更多信息。 I'm pretty new to PHP that would help a lot too, to know. 我对PHP还是很陌生,这对我很有帮助。

Thanks for bearing with me! 感谢您的支持! Sorry about a repeat topic. 很抱歉重复一个话题。

code: 码:

<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;

This line: 这行:

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();
?>

Your query preparation contains zero parameters, since you just dumped the values in there, completely defeating the purpose of prepared statements. 您的查询准备包含零个参数,因为您只是将值转储到那里,从而完全违反了准备好的语句的目的。 Instead, try this: 相反,请尝试以下操作:

 if (!($stmt = $mysqli->prepare("INSERT INTO table(id, name, votes) VALUES (?,?,?)"))) {

Then continue as you are. 然后照原样继续。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Mysqli:mysqli_stmt :: bind_param():变量数与准备好的语句中的参数数不匹配 - Mysqli:mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement mysqli_stmt :: bind_param():变量数与准备好的语句中的参数数不匹配 - mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement mysqli_stmt :: bind_param():变量数量与php中准备好的语句中的参数数量不匹配 - mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement in php mysqli_stmt :: bind_param变量数与准备好的语句中的参数数不匹配 - mysqli_stmt::bind_param Number of variables doesn't match number of parameters in prepared statement (PHP)警告:mysqli_stmt :: bind_param():变量数与准备好的语句中的参数数不匹配 - (PHP) Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement 警告:mysqli_stmt::bind_param():变量数与 C:\User..\ on 148 中准备好的语句中的参数数不匹配 - Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement in C:\User..\ on 148 PHP 警告:mysqli_stmt::bind_param():变量数与准备好的语句中的参数数不匹配 - PHP Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement mysqli_stmt :: bind_param():第64行上已准备好的语句中的变量数量与参数数量不匹配 - mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement on line 64 call_user_func_array()-警告:mysqli_stmt :: bind_param():变量数与准备好的语句中的参数数不匹配 - call_user_func_array() - Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement mysqli_stmt::bind_param() [mysqli-stmt.bind-param]:变量数量与参数数量不匹配 - mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of variables doesn't match number of parameters
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM