致命错误调用未定义函数mysqli_stat_bind_param()

时间:2015-09-09 06:29:03

标签: php sqlbindparameter

我有以下的PHP脚本

<?php

$con=mysqli_connect("localhost","root","");
if(!$con)
    {
        die('Could not connect'.mysqli_error());
    }
mysqli_select_db($con,"mysql");
$username=$_POST["username"];
$password=$_POST["password"];
$statement=mysqli_prepare($con,"Select * from bbau_login where username=? and password=?");
mysqli_stat_bind_param($statement,$username,$pasword);
mysqli_stat_execute($statement);
mysqli_stat_store_result($statement);
mysqli_stat_bind_result($statement,$id,$name,$username,$password);

$user=array();

while(mysqli_stat_fetch($statement))
    {
        $user[name]=$name;
        $user[username]=$username;
        $user[password]=$password;
    }
echo json_encode($user);
mysqli_stat_close($statement);
mysqli_close($con);

?>

但是每当我调用tis脚本时,我都会得到错误 致命错误调用未定义函数mysqli_stat_bind_param() 请帮忙解决这个问题

1 个答案:

答案 0 :(得分:1)

您必须将mysqli_stat_*来电更改为mysqli_stmt_*来电。

使用关联数组时也应该使用引号:

$user['name'] = $name;
$user['username'] = $username;
$user['password'] = $password;

而不是

$user[name]=$name;
$user[username]=$username;
$user[password]=$password;