PHP支持希伯来语

时间:2017-08-14 13:18:23

标签: php mysql mysqli hebrew

下面的字符串以Gibberish而不是希伯来语到达服务器,请帮助,这是我的代码的样子(我得到长字符串并将每个部分插入到数据库中)? 例如,名称插入为; לירןמדקורה

        <?php

    $data_to_server = $_POST['data_to_server'];
    $length = $_POST['length'];

    $servername = "";
    $username = "";
    $password = "";
    $dbname = "";

    $conn = new mysqli($servername, $username, $password, $dbname);

    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    } 

    $users_list = $data_to_server;

    $users_list = str_replace(array("phone:","name:","event_id:"),array("","",""),$users_list);

    //$users_num = 4;
    $sql_str = "INSERT INTO invite_list (phone,name,event_id) VALUES ";


    for ($i=0; $i<$length; $i++){

      $temp_list = "";
      $temp_list = substr($users_list, 0, strpos($users_list, '/'));
      $users_list = str_replace($temp_list."/","",$users_list);
      $sql_str = $sql_str . "(" . $temp_list;


      if ($i < $length-1)
          $sql_str = $sql_str . "),";
      else
          $sql_str = $sql_str . ");";
    }

    $sql = $sql_str;

if ($conn->query($sql) === TRUE) {
    echo json_encode(array("Result"=>"success"));

} else {
    echo json_encode(array("Result"=>"failed"));
}

$conn->close();

1 个答案:

答案 0 :(得分:1)

可能不是PHP有问题;还要验证MySQL是否使用UTF8连接,并且表(和列)是UTF8。