Reputation: 121
i trying to put hebrew at mysql DB and i read all the answer and it didn't work. i can put hebrew value with php my admin so the problem must be at the script. i try use:
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();
?>
Upvotes: 0
Views: 873
Reputation: 150
mysqli_set_charset() should be 'utf8' not 'utf-8'. Also I believe it should be mysqli_set_charset($connector, 'utf8');
Upvotes: 1