A data error occurs when php submits data to mysql.-php Tutorial

Source: Internet
Author: User
An error occurred while submitting data to mysql in php.
$sql = "insert into ecs_goods(cat_id,goods_sn,goods_name,goods_name_style,goods_number,market_price,shop_price,warn_number,goods_desc,is_real,is_on_sale,is_alone_sale,add_time,sort_order,is_new,give_integral,rank_integral,goods_type) values ('".$goods_type."','".$goods_sn."','".$goods_name."',"."'+'".",9999,".$shop_price.",".$shop_price.",1,\"".$str2."\",1,1,1,'".time()."',100,0,-1,-1,". $goods_type_type .")";


The $ str2 variable contains about characters. other data is normal when it is submitted, but the data submitted for this variable is only a short section above, but it is strange that, I used the same SQL statement in phpmyadmin to include all the variables for execution, but the execution was successful ..


Reply to discussion (solution)

Is there a limit on the length of database fields?

What should I modify if there are limits?

Is there a limit on the length of database fields?


What should I modify if there are limits?

What is the SQL statement executed by phpmyadmin?
In addition, what type is your field.

What is the SQL statement executed by phpmyadmin?
In addition, what type is your field.


Text
I used echo to output the $ SQL statement executed by phpmyadmin and then submitted it.

Create a stored procedure and insert 2 W characters of data at a time. What makes PHP feel like!

Too abnormal !~ @~~~

Sit wait

The name of a field is 2 W characters, which is unknown.

It is best to post mysql errors for analysis.
Mysql_query ($ SQL) or die (mysql_error ());

I have never had such a large field, so I am not sure

Modify max_allowed_packet = 8 M in the mysql configuration file (my. ini ).

Isn't the encoding set?

Solved it by yourself. modified the data storage format.

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.