Why can't I add numbers and English letters to add data in php?

Source: Internet
Author: User
Tags add numbers php mysql
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.