为什么mysqli_num_rows($ result)没有返回任何值?

时间:2016-06-17 00:00:17

标签: php mysqli

我有以下代码

<?php
$servername = "localhost";
$username = "user";
$password = "pass";
$dbname = "database";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

$sql = "SELECT id, name, time, order FROM main";
$result = mysqli_query($conn, $sql);

$num = mysqli_num_rows($result);
echo "Stuff: " . $num;

mysqli_close($conn);
?>

出于某种原因,上传到我的服务器并在我的网络浏览器上运行时,这不会返回值。任何人都可以理解为什么会这样吗?

非常感谢

0 个答案:

没有答案