PHP Connection SQL file encoding problem, the last patch, and problems, solve
I am using PHP database connection, when the data is stored in the problem, but with PHP to the data encoding method has been modified,
===========================================
Iconv ("Utf-8", "GBK", $array [2])
===========================================
The deposit is correct, but is to take out the data when the problem, think again with the original way back, but no way to change back ...
When I take Chinese and print it to a webpage, it becomes "??" ”... Want to be the problem of data encoding, just do not know how to unify
My PHP code is to use the UTF8 database is also UTF8, is not and the browser encoding is also related? ...
I have the error page below. PHP Database
------Solution--------------------
mysql_query ("Set names UTF8"); Add this sentence before executing a query
Prevent page output garbled can be added at the beginning of the PHP file: header ("Content-type:text/html;charset=utf-8");
------Solution--------------------
$link = @mysql_connect (Host,user,pass) or Die ("database connection failed");
mysql_select_db (DBNAME, $link);
mysql_query (' Set names UTF8 ');
$sql = "SELECT * from Users where username= ' {$username} ' and state=1";
$result =mysql_query ($sql, $link);
Before sending the SQL statement, add mysql_query (' Set names UTF8 ');Can be solved, the premise is that the data is Chinese, can not be garbled!
------Solution--------------------
This is very your database coding problems, you go into the MSYQL database to see, there is mysql_query ("Set names UTF8"), and then there is the Web page BOM problem. If you can't solve it, just put it on the hook.