Character set in MySQL; Can't insert special characters, why?
I can't insert special characters. Whenever I try to, all characters BEFORE the special character gets inserted, but after the special character nothing is inserted into the field.
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
mysql_select_db($dbname,$conn);
mysql_set_charset('utf-8', $conn);
mysql_query("SET NAMES 'utf8'") or die(mysql_error());
mysql_query("SET CHARACTER SET 'utf8'") or die(mys开发者_StackOverflowql_error());
I have set the table to utf-8 collation, and all fields as well...
Any thoughts?
Thanks
Have you set the necessary UTF-8 parameters in your PHP config? I used to begin my PHP files with that:
ini_set("mbstring.internal_encoding","UTF-8");
ini_set("mbstring.func_overload",7);
I had same issue for saving special characters in mysql database so i changed Collation to utf8mb4_unicode_ci, it made the sql query run and complete data was inserted into database. But special characters not supported with UTF-8 are replaced by '?'. But I found it better till permanent fix atleast full data is inserted into database.
精彩评论