把希伯来语放在mysql上

时间:2012-03-23 17:30:30

标签: php mysql utf-8 mysqli hebrew

我试图把希伯来语放在mysql DB上,我读了所有的答案,但它没有用。 我可以用php我的管理员把希伯来价值放在一起,所以问题必须在脚本上。 我尝试使用:

1.header()。

2.set name utf-8。

3.mysql_set_charset()。

<?php   
$cate_name=$_POST['cate_name'];


$query="INSERT INTO project_food_cate (name) VALUES(?)"; 

$connector=new MySQLi("localhost","[redacted]","[redacted]","users");

        /*this code need to put the a privalage to use hebrew values for the rows*/
    header('Content-Type:text/html; charset=utf-8');
    mysql_query("SET character_set_client=utf8"); 
    mysql_query("SET character_set_connection=utf8"); 
    mysql_query("SET character_set_database=utf8"); 
    mysql_query("SET character_set_results=utf8"); 
    mysql_query("SET character_set_server=utf8"); 
    mysql_query("SET NAMES utf8");

    mysqli_set_charset('utf-8',$connector); 



    $charset = mysql_client_encoding($connector);
        echo "The current character set is:".$charset."\n"; //not giving a     value.

    /***************************************************************/


if (mysqli_connect_errno())
    {
        echo "error has been happend";
        exit();
    }


$stmt=$connector-> prepare($query);
$stmt-> bind_param("s",$cate_name);
$stmt-> execute();
echo $stmt-> affected_rows." has enter to this DB";

$stmt->free();
$stmt->close();
?> 

1 个答案:

答案 0 :(得分:1)

mysqli_set_charset()应该是'utf8'而不是'utf-8'。 另外我认为它应该是mysqli_set_charset($ connector,'utf8');