问题Fatal error: Call to a member function bind_param() on a non-object in
<?php header('content-type:text/html;charset=utf-8'); $mysqli=new mysqli('localhost','root','','tamia'); if ($mysqli->errno) { die("Connect Error:".$mysqli->error); } $mysqli->set_charset('UTF8'); $username=$_POST['username']; $password=md5($_POST['password']); /*$sql="SELECT * FROM users WHERE username='{$username}' AND password='{$password}'"; $mysqli_result=$mysqli->query($sql); if($mysqli_result && $mysqli_result->num_rows>0){ echo '登录成功'; }else{ echo '登录失败'; }*/ $sql="SELECT * FROM user WHERE username=? AND password=?"; $mysqli_stmt=$mysqli->prepare($sql); $mysqli_stmt->bind_param('ss',$username,$password); if ($mysqli_stmt->execute()) { $mysqli_stmt->store_result(); if ($mysqli_stmt->num_rows>0) { echo '登录成功'; }else{ echo '登录失败'; } } //释放结果集 $mysqli_stmt->free_result; //关闭预处理语句 $mysqli_stmt->close(); //关闭连接 $mysqli->close(); ?>
老师的源代码也是如此,请问是什么问题