致命错误:调用未定义方法mysqli :: bind_param() [英] Fatal error: Call to undefined method mysqli::bind_param() in
本文介绍了致命错误:调用未定义方法mysqli :: bind_param()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这里找不到故障对您有帮助吗?这是我的错误
I can not find fault here you help? This is my error
致命错误:在
Fatal error: Call to undefined method mysqli::bind_param() in
我不知道怎么了
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST))
{
$login = $_POST['login'];
$password = $_POST['password'];
$email = $_POST['email'];
if(empty($login) || empty($password) || empty($email))
{
die('Comeplete all text.');
}
elseif(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
die('Nie poprawny adres E-mail.');
}
else
{
include_once('config.php');
$mysqli = new mysqli('****', '******', '*****') or die ('Fatal Error: '.mysql_error());
if($mysqli -> connect_error)
die('Error Connection:'.$mysqli -> connect_error.'['.$mysqli -> connect_errno.']');
$login = trim(htmlspecialchars($mysqli -> real_escape_string($login)));
$password = hash('sha256', trim(htmlspecialchars($mysqli -> real_escape_string($password))));
$email = trim(htmlspecialchars($mysqli -> real_escape_string($email)));
$ip = $_SERVER['REMOTE_ADDR'];
$stmt = $mysqli -> prepare("INSERT INTO `user`(`id_user`, `login`,`password`,`email`,`added`,`ip`) VALUES('', ? , ? , ? , now(), ?)");
$stmt = $mysqli -> bind_param("ssss", $login, $password, $email, $ip);
if ($stmt) {
$stmt->execute();
echo 'Success';
}
}
}
?>
</section>
</body>
</html>
推荐答案
问题是,您在MySQL上使用的是bind_param
函数,而不是$stmt
变量.
The problem is, you're using bind_param
function on MySQL and not the $stmt
variable.
问题出在这一行:
$stmt = $mysqli -> prepare("INSERT INTO `user`(`id_user`, `login`,`password`,`email`,`added`,`ip`) VALUES('', ? , ? , ? , now(), ?)");
$stmt = $mysqli -> bind_param("ssss", $login, $password, $email, $ip);
代替输入:
$stmt = $mysqli->bind_param("ssss", $login, $password, $email, $ip);
您应该输入:
$stmt = $stmt->bind_param("ssss", $login, $password, $email, $ip);
因为bind_param
方法仅在mysqli_stmt
类上可用.而不是mysqli
.
Since the bind_param
method is only available on the mysqli_stmt
class. and not the mysqli
.
在此处签出文档.
这篇关于致命错误:调用未定义方法mysqli :: bind_param()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文