When trying this insert query:
//insert into database
$contact_id = db_insert('contact')
->fields(array(
'date_created' => date("Y-m-d H:i:s"),
'date_updated' => date("Y-m-d H:i:s"),
'list_id' => $form_state['values']['list_id'],
'first_name' => $fn,
'last_name' => $ln,
'gender' => $g,
'email' => $ea,
'company_name' => $cn,
'is_active' => 1,
))
->execute();
Everything works fine, all the data is loading fine, but when the company name gets an accent, then it causes an error “The website encountered an unexpected error.” and the logs just say ‘error’ on that particular line. Removing the row with the accent solves the problem, but I need to be able to add that accent. If I make the database connection outside of the Drupal way (just mysql_query(“INSERT INTO…”)) it works fine.
The company name is like: Johns Industriële Company
Database is utf8, table and fields utf8
Hope someone can shed some light on this mystery!
This could be an encoding issue in the input. If
$cn ="Johns Industriële Company";is stored in for example ISO-8859-1, the sequenceële(which in that case should be the byte sequenceeb 6c 66) will represent an invalid UTF-8 sequence that the database should reject.Try examining the encoding and bytes of the submitted data.