By oskar_calvo on
Hello, i'm trying to use the form_altern in drupal 6.x, but I get a drupal error:
Here is my code:
function ayuda_form_alter(&$form, $form_state, $form_id){
// print_r ($form_id); para saber la identidad del formulario
// print_r ($form); para conocer las características de todos los campos del form
if($form_id == 'stormproject_node_form'){
//unset ($form['log']); // borra el campo 'Mensaje de registro' del tipo de contenido 'receta_node_form'
unset ($form['group1']['organization_nid']['#options']);
$result = db_query("SELECT nid, title FROM {node} WHERE type = '%s' AND STATUS =%d", array('stormorganization', 1));
$options = array();
while(list($nid, $title) = mysql_fetch_row($result)){
$options [$nid] = $title;
}
//$options = array('si','no');
$form['group1']['organization_nid'] = array (
'#type' => select,
'#title' => Organization,
'#options' => $options,
);
echo '<pre>';
print_r ($form);
echo '</pre>';
}
}
And the mistake is:
warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /var/www/storm/sites/all/modules/ayuda/ayuda.module on line 21.
I have check the query in phpmyadmin, and it gives me a result with two rows.
Thanks
Oskar
Comments
Since you are using Drupal
Since you are using Drupal you should be using the db* functions. Drupal provides db_fetch_object() and db_fetch_array(), I would try using one of these.
Thanks Nevets. I change to
Thanks Nevets.
I change to
db_fetch_objectand it works great.Thanks a lot.
Oskar