有人可以告诉我为什么这不是返回行数请

时间:2017-12-09 11:47:19

标签: php mysqli

printf似乎没有工作,没有收到错误

require_once('settings.php');

    $link = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);

    if(!$link)
        {

        die("Error " . mysqli_connect_error());
        }

    $query = "SELECT * FROM 'testarea'";
    if($result = mysqli_query($link, $query)){
        printf($result->num_rows); // Trying to get back number of rows
    };

    mysqli_close($link);

1 个答案:

答案 0 :(得分:0)

只需从表名

中删除单引号即可

$query = "SELECT * FROM testarea";