我不明白为什么我没有进入num_rows
mysqli。
代码:
$MysqlHost='localhost';
$MysqlUser='test';
$MysqlPassword='password';
$MysqlDatabase='test_data';
function mysqli($query){
$mysqli = new mysqli($GLOBALS["MysqlHost"],$GLOBALS["MysqlUser"],$GLOBALS["MysqlPassword"],$GLOBALS["MysqlDatabase"]);
if (mysqli_connect_errno()) {
printf("Bad connect: %s\n", mysqli_connect_error());
exit();
}
$result = $mysqli->query("SET NAMES utf8");
$result = $mysqli->query("set character_set_client='utf8'");
$result = $mysqli->query("set collation_connection='utf8_general_ci'");
$result = $mysqli->query($query);
$mysqli->error;
$result->error;
$mysqli->close();
return $result;
};
$res_user=mysqli("SELECT * FROM table");
print $res_user->num_rows;
我得到空的结果,不是null(0)
,只有空的......
知道为什么会这样吗?