PHP文件什么也不返回

我正在使用下面的代码,它连接到MySql,不幸的是它不返回任何内容。我想知道我犯了什么错误。

她是代码:

<?php

$host = "localhost"; // Host name 
$username = "*******"; // Mysql username 
$password = "*******"; // Mysql password 
$db_name = "*******"; // Database name 
$tbl_name = "*******"; // Table name 

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

mysql_set_charset('utf8');

$sql="SELECT * FROM $tbl_name";

mysql_query("SET NAMES 'utf8'"); //5
$result = mysql_query($sql);

// Mysql_num_row is counting table row
$count = mysql_num_rows($result);

$count = 0;
$items;

while($row = mysql_fetch_array($result)) {
    $item['name'] = $row['name'];
    $item['address'] = $row['address'];
    $item['latitude'] = $row['latitude'];
    $item['longtude'] = $row['longtude'];
    $items[$count++] = $item;
}

//echo json_encode($items);
echo json_encode($items, JSON_UNESCAPED_UNICODE);
?>

请给我建议。

评论