I'm trying to programmatically insert a node with a UNICODE character in the body. The result was that the node was inserted but the body that has the unicode character is blank. It also throws the following error:

PDOException: in field_sql_storage_field_storage_write() (line 425 of /home/dtipsadm/public_html/modules/field/modules/field_sql_storage/field_sql_storage.module).

I've tried different collation for the field_data_body table and fields such as utf8_general_ci, and latin1_swedish_ci but still it did not solve the problem.

I've tried passing the body text to mysql_real_escape_string but it says that mysql_real_escape_string is denied access. It's because I need to pass the database connection link resource. By the way, how to get this connection resource link?

Here's how I added the node:

...
$node->body[$node->language][0]['value'] = 'the quick “brown fox” jumps';
...
node_save($node);

The code above has no problem with contents without the unicode character (quotes)

Also tried something like this:
...
$node->body[$node->language][0]['value'] = mysql_real_escape_string('the quick “brown fox” jumps');
...
node_save($node);

Anyone?

Comments

Mark Vincent Verallo’s picture

Take note that the quotes are the unicode characters.

bdsl’s picture

Subscribing. This is the same issue as Truncation problem with $node->body on node_save($node).