I am using the below code which is connect to MySql, unfortunately it does not return anything. I am wondering what mistake I made.
Her is the code:
<?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);
?>
Please advice me.