Php 无法显示阿拉伯语内容
我试图从mysql数据库排序规则utf8_general_ci中获取阿拉伯语数据,但在数据库中插入数据时效果很好。当我试图获取数据时,它给了我一些不同的符号Php 无法显示阿拉伯语内容,php,android,database,Php,Android,Database,我试图从mysql数据库排序规则utf8_general_ci中获取阿拉伯语数据,但在数据库中插入数据时效果很好。当我试图获取数据时,它给了我一些不同的符号 //*$response = array(); $username = "root"; $password = ""; $hostname = "localhost"; //connection to the database $dbhandle = mysql_connect($hostname, $username, $pass
//*$response = array();
$username = "root";
$password = "";
$hostname = "localhost";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
//select a database to work with
$selected = mysql_select_db("tellmedb",$dbhandle)
or die("Could not select tellmedb");
//execute the SQL query and return records
mysql_query("SET NAMES utf8");
mysql_query("set characer set utf8");
$result = mysql_query("SELECT * FROM tbl_restaurantara") or die(mysql_error());
// Check whether there is data(record more than 0)
if (mysql_num_rows($result) > 0)
{
// looping result mysql_query
$response["list_rs"] = array();
while ($row = mysql_fetch_array($result))
{
// temp user array
$list_rs = array();
$list_rs["id_rs"] = $row["id"];
$list_rs["name_rs"] = stripslashes($row["name"]);
$list_rs["link_image_rs"] =
stripslashes($row["link_image"]);
$list_rs["url1_rs"] =
stripslashes($row["url1"]);
$list_rs["url2_rs"] =
stripslashes($row["url2"]);
$list_rs["url3_rs"] =
stripslashes($row["url3"]);
$list_rs["address_rs"] =
stripslashes($row["address"]);
$list_rs["telepon_rs"] =
stripslashes($row["phone"]);
$list_rs["booking_rs"] =
stripslashes($row["bookingurl"]);
$list_rs["offer_rs"] =
stripslashes($row["offersurl"]);
$list_rs["location_rs"] =
stripslashes($row["location"]);
// display the query results in the form of an array
array_push($response["list_rs"], $list_rs);
}
// success
$response["success"] = 1;
// echoing JSON response
echo json_encode($response,JSON_UNESCAPED_UNICODE);
}
else {
// No data
$response["success"] = 0;
$response["message"] = "No DATA";
// echoing JSON response
echo json_encode($response,JSON_UNESCAPED_UNICODE);
}
//close the connection
mysql_close($dbhandle); */
产出如下:
/*وعب، أسباير زوÙ*/
首先,请确认阿拉伯语文本是否正确保存在数据库中,如果可以,请在从代码中删除这一行后重试
mysql_query("set characer set utf8");
加
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
此代码
如果阿拉伯语文本未正确保存在数据库中,请将数据库排序规则更改为UTF-8。尝试以下操作:
// connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
mysql_set_charset('utf8', $dbhandle);
还要删除此行:
mysql_query("set characer set utf8");
请参阅讨论修复拼写:删除mysql后将set character set utf8更改为set character set utf8\u queryset character set utf8 get all?????marks现在也尝试更改排序规则。仅在获取时出现问题Orry仍然获取\u0641\u0648\u0631\u0633\u064a\u0632\u0648\u0646\u0632这可能是json问题吗?谢谢大家,它解决了json问题。非常感谢你们的回复