Hi,

I try to get the node id from the database and I get an error message:

user warning: Unknown column 'my article' in 'where clause' query: SELECT nid FROM node WHERE title = my article in /var/www/my-site.com/sites/all/modules/mymodule/mymodule.module on line 305.

function mymodule_mail_alter(&$message) {
	switch($message['id']) {
		default :
			$account = $message['params']['account'];
			$nid = db_query("SELECT nid FROM {node} WHERE title = $account->b_name");
	}
}

Thanks for your help.

Comments

yelvington’s picture

Perhaps you meant something like this:
$nid = db_query("SELECT nid FROM {node} WHERE title = '%s'", $account->b_name);

http://api.drupal.org/api/function/db_query/6

User-supplied arguments to the query should be passed in as separate parameters so that they can be properly escaped to avoid SQL injection attacks.