Cannot insert full html data to Database

syrgakt - May 15, 2008 - 09:09

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

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, http://localhost/medialaw/files/images/15_05_08-03_06_25_img.jpg

alt=\"Uploaded Image\" />) 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.

That clinches it, yet!

syrgakt - May 16, 2008 - 06:48

That clinches it, yet!

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

i.e. '%s'.

Thanks.

 
 

Drupal is a registered trademark of Dries Buytaert.