⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

UTF-8 error in mySql when updating field via GroceryCrud - no error when updating manually



elia novi

elia novi
  • profile picture
  • Member

Posted 20 February 2013 - 13:30 PM

Hi guys,

I have a problem with utf-8 encoding which seems to be related to GroceryCrud implementation (or at least that's my guess).

 

Let me explain the situation first:

I have a date field (which is actually a string field because i also needed the localized day of the week inside), and is populated with a jQuery Datepicker set of values. In this specific case i use a localized version of jQuery which contains letters like ì,è, etc. for the weekday.

 

So, the situation is this one: there are two places where you can set the value of this filed in the website : one is the classic edit/add item (i use the field as text and i use a callback field to render the text filed as a datepicker field in order to have the same behavior as if it was a date field) and the other one is in the result table, where i used a callback column to render an input text if the column value is empty which triggers datepicker in order to have better date insertion. (and a custom save button that posts data to my controller).

 

Everything is utf-8: tables are, fields are utf8_unicode_ci and the html has utf-8 as charset. 

 

If i post the value of the jquery datepicker containing something like this:

 

data['shippingDate'] = 'Venerd\xEC, 22 Febbraio 2013' 

 

from the jquery.post() code i wrote to handle inputs from the results table, everything works.

 

But, if i post the same kind of data, to the same field of the sql table, from the edit page (the default edit form), i get this error : ERROR - 2013-02-20 13:49:49 --> Query error: Incorrect string value: '\xEC, 22 ...' for column 'shippingDate' at row 1

 

This seems like GroceryCrud tries to perform or do something with the value that i don't do with my custom post, and breaks stuff. In fact, inserting the same utf chars 'Venerd\xEC, 22 Febbraio 2013' in the field via phpMyAdmin works perfectly.

 

Can you please help me out with this ? I tried to see where this happens, but i got lost in the grocery_crud.php file... I'm not an expert php developer unfortunately :(

 

Thanks a lot for the help... and keep up with the good work ! ;)