Hi, all.
Currently I'm developing custom node module that contains field for image source (Only local images are allowed.).

I've declared it as hidden textarea with "Full HTML" filter:

$form['imgsrc'] = array('#type' => 'textarea',
'#id' => 'imgsrc',
'#required' => TRUE,
'#default_value' => $node->imgsrc,
'#attributes'=> array('style' => 'display:none')
);

$form['imgsrc']['filter'] = filter_form(3);//Full HTML

Further, during creating custom node JavaScript via zero iframe uploads the image to the server (in /files/images/) and returns src attibute for img element.

Problem is that i cann't store this data in database:

function prima_insert($node){
drupal_set_message(t('The custom node has been created.'));
db_query("INSERT INTO {prima} (nid, vid, head, imgsrc, dest) VALUES (%d, %s, %s, %s)", $node->nid, $node->vid, $node->head, $node->imgsrc, $node->dest);
}

So, i've an error message when trying save new created node (in hook_insert):

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'header message, Only local images are allowed.) in z:\home\localhost\www\medialaw\includes\database.mysql.inc on line 172.

Can anyone see some workaround for this issue? Any help is highly appreciated.

Comments

jetunseen’s picture

That clinches it, yet!

The problem was trivially solved by rounding the %s by '':

i.e. '%s'.

Thanks.