0
我試圖把希伯來語放在mysql數據庫,我讀了所有的答案,它沒有奏效。 我可以把PHP的希伯來語價值我的管理員,所以問題必須在腳本。 我嘗試使用:把希伯來語放在mysql
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();
?>
你在混合'mysqli'和'mysql'。 – thirtydot 2012-03-23 17:50:55
如果你使用mysqli,那麼mysql_ *函數不會爲你做任何事情;他們來自不同的圖書館。 – 2012-03-23 17:51:24
表'project_food_cate'中的字段'name'定義了什麼字符集?另外請注意,你發送的'header()'應該聲明'utf-8'而不是'utf8'。 – Yaniro 2012-03-23 17:52:20