PHP Add data Why can only fill in the numbers and English, add text will be error

Source: Internet
Author: User
Tags php mysql
PHP MySQL

Write a piece of code in PHP, add data can only fill in numbers and English, add text will be error, ask a master to help me solve the next problem.
The following is an error:
Execution error Incorrect string value: ' \xe8\xb4\xb9\xe6\x98\xaf ' for column ' N_content ' at row 1
Here's the code:
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 ' Insert success ';
}else{
Echo ' Insert failed ';
}
Mysql_close ($con);
}
Mysql_close ($con);
?>





<title></title>

<title>Auto Height Examples</title>











Reply to discussion (solution)

Your database default encoding is ASCII?

Finally find out where the problem is.
Change the configuration in MySQL My.ini my.ini find Sql-mode, default to Sql-mode= "Strict_trans_tables,no_auto_create_user,no_engine_substitution ", modify it to sql-mode=" no_auto_create_user,no_engine_substitution "and restart MySQL

  • 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.