我正在尝试从 mysql 数据库排序规则 utf8_general_ci 中获取阿拉伯语数据,但是在数据库中插入数据时工作正常。当我尝试获取数据时,它给了我一些不同的符号。
//*$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); */
输出如下:
/*وعب، أسباير زوÙ*/