这是我在本地“开发”服务器上使用的代码,但不幸的是我的远程服务器不支持mysqli本机驱动程序 - 如何替换mysqli_stmt_get_result();
?
CODE:
$query = "SELECT * FROM class WHERE email = ? AND password = ?";
$stmt = mysqli_prepare($connect,$query);
mysqli_stmt_bind_param($stmt,'ss',$nickname,$password);
mysqli_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$row = mysqli_fetch_assoc($result);
include("year_tester.php");
if(mysqli_num_rows($result) != ""){
$_SESSION['loggedIn'] = true;
$_SESSION['loginName'] = $nickname;
$_SESSION['classIdentify'] = $rocnik.".".$className;
header('Location: index.php');
}
答案 0 :(得分:0)
...在PDO中重写它是否可以接受? :P
$pdoh=new PDO("mysql:host=127.0.0.1;dbname=testdb;charset=utf8",
$mysqldb_username,$mysqldb_password,
array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
$query = "SELECT * FROM class WHERE email = ? AND password = ?";
//$stmt = mysqli_prepare($connect,$query);
$pdosh=$pdoh->prepare($query);
//mysqli_stmt_bind_param($stmt,'ss',$nickname,$password);
//i feel sorry for the guy writing the garabage collector :(
$pdosh->bindParam(1,$nickname, PDO::PARAM_STR);
$pdosh->bindParam(2,$password, PDO::PARAM_STR);
//mysqli_execute($stmt);
$pdosh->execute(); //using ERRMODE_EXCEPTION right?
//$result = mysqli_stmt_get_result($stmt);
//$row = mysqli_fetch_assoc($result);
$row=$pdosh->fetch();
require("year_tester.php");
if($pdosh->rowCount()>0/*mysqli_num_rows($result) != ""*/){
$_SESSION['loggedIn'] = true;
$_SESSION['loginName'] = $nickname;
$_SESSION['classIdentify'] = $rocnik.".".$className;
header('Location: index.php');
}