Why can't I add numbers and English letters to add data in php? an error occurs when I add text to PHP MySQL.
I wrote a piece of code in php. I can only add numbers and English characters to add data. an error will be reported when I add the text. a bit expert will help me solve the next problem.
The following error is reported:
Execution error Incorrect string value: '\ xE8 \ xB4 \ xB9 \ xE6 \ x98 \ xAF...' for column 'n' _ Content' at row 1
The following code is used:
Header ("Content-Type: text/html; charset = utf-8 ");
If ($ _ POST ['submit ']! = ""){
$ I = $ _ POST ['id'];
$ T = $ _ POST ['title'];
$ C = $ _ POST ['content'];
$ Con = mysql_connect ("localhost", "root", "root ");
Mysql_select_db ("test", $ con );
$ SQL = "INSERT INTO news (n_id, n_title, n_content) VALUES (NULL, '$ t',' $ c ');";
Echo $ SQL;
$ Rat = mysql_query ($ SQL, $ con) or die ('execution error'. mysql_error ());
If ($ rat ){
Echo 'successful insert ';
} Else {
Echo 'insertion failed ';
}
Mysql_close ($ con );
}
Mysql_close ($ con );
?>
Auto Height Examples