Bug #42372 Data truncate while inserting from PHP
Submitted: 27 Jan 2009 13:02 Modified: 29 Jan 2009 12:21
Reporter: Jitendra Rathod Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Charsets Severity:S1 (Critical)
Version:5.0.27 OS:Any
Assigned to: CPU Architecture:Any
Tags: character set, Data truncate, Data truncated for column

[27 Jan 2009 13:02] Jitendra Rathod
Description:
Hello,

My Data is truncated when I will Insert it from PHP.
When I will insert it from PHPMyAdmin, it will save OK.

first create table;

CREATE TABLE `gjcrawling_job44` (
  `titledesc` varchar(255) NOT NULL default '',
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Insert below value from PHP's mysql_query function.

INSERT IGNORE INTO gjcrawling_job47 (`titledesc`) VALUES('Brand Development Specialist / Spécialiste, Développement de la marque – TOR01996')

It will only inserts the 'Brand Development Specialist / Sp' into the table.

Waiting your reply.

Thanks,
Jitendra

How to repeat:
first create table;

CREATE TABLE `gjcrawling_job44` (
  `titledesc` varchar(255) NOT NULL default '',
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Insert below value from PHP's mysql_query function.

INSERT IGNORE INTO gjcrawling_job47 (`titledesc`) VALUES('Brand Development Specialist / Spécialiste, Développement de la marque – TOR01996')

It will only inserts the 'Brand Development Specialist / Sp' into the table.
[27 Jan 2009 20:55] Sveta Smirnova
Thank you for the report.

But version 5.0.27 is old. Please upgrade to current version 5.0.67 and try with it.

Additionally this look like "Not a Bug" for me: please make sure your PHP application uses correct encoding when inserts data. See also http://dev.mysql.com/doc/refman/5.0/en/charset.html and http://dev.mysql.com/doc/refman/5.0/en/charset-applications.html
[28 Jan 2009 5:11] Jitendra Rathod
Thanks for quick reply.

But we have also tried this issue with current version 5.0.67 on other server and same problem occure.

Also I have tested PHP encoding in so many ways and the current which I have used is I think the correct one.

I have already posted bug for the same type at here few days ago and still I am not getting the proper answer from your side. And just give me the message that this is 'Not a but'.

If there is not any solution for this case then please give me message that not any solution for that.. dont tell that this is 'Not a bug'. Because I have wasted my 1 month to solve this problem.

Thanks,
Jitendra
[28 Jan 2009 5:15] Jitendra Rathod
Also when I am trying to insert the record from PHP side it will give me the warning like this..

 [0] => Warning
 [Level] => Warning
 [1] => 1265
 [Code] => 1265
 [2] => Data truncated for column 'titledesc' at row 1
 [Message] => Data truncated for column 'titledesc' at row 1

I think it will helpful to understand the problem.

Thanks,
Jitendra
[29 Jan 2009 12:21] Susanne Ebrecht
Many thanks for writing a bug report.

This is not a bug. You produced an encoding mix between ISO-8859-X charset and UTF8.

Please check encoding of your browser.

We're sorry, but the bug system is not the appropriate forum for asking help on using MySQL products. 

Support on using our products is available both free in our forums at http://forums.mysql.com/ and for a reasonable fee direct from our skilled support engineers at http://www.mysql.com/support/

Thank you for your interest in MySQL.