000webhost的資料庫編碼修正(utf-8)
$sql="INSERT INTO ". db('tablename') . " (area_id,name,address, lat, lng) VALUES('$city','$name','$address','$lat','$lng')";
$db_link = mysql_connect(db('hostname'),db('username'),db('password'));
mysql_select_db(db('dbname'), $db_link);
mysql_query("SET NAMES 'utf8'", $db_link);
//$sql="INSERT INTO cafe_map SET name='".$name."'";
mysql_query($sql, $db_link);
echo mysql_error($db_link);
$con=mysqli_connect(db('hostname'),db('username'),db('password'),db('dbname'));
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$con->query("SET NAMES 'utf8'");
$result = mysqli_query($con,"SELECT * FROM ".db('tablename'));
while($row = mysqli_fetch_array($result))
{
$LatLng = "(".$row['lat'].",".$row['lng'].")";
$item_id =$row['id'];
$ScenicName =$row['name'];
$phpecho = $phpecho.$row['id'].$LatLng;
$locations_db_json.='{';
$locations_db_json.= 'latlng : new google.maps.LatLng';
$locations_db_json.= $LatLng;//'(25.0336148,120.56480220000003)';
$locations_db_json.=',';
$locations_db_json.= 'info :';
$locations_db_json.= '"'.$row['id'].":".$ScenicName.'"'; ;//'"hello"'; $markerName
$locations_db_json.= '},';
}
mysqli_close($con);
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。