[support] How can I get the error message from database

Todd todd at savagevenus.net
Wed Jan 11 21:34:20 UTC 2012


If you use devel.module, you can use db_queryd, which will give you any error messages that are returned by an invalid query.

http://api.drupal.org/api/devel/devel.module/function/db_queryd/6

Regards,
Todd

On 11 Jan 2012, at 16:13, robert mena wrote:

> For some reason one of my queries is not executing.  I've used the
> db_error() but I only get 0.    I'd like to know how can I get the
> error message.
> 
> I am using drupal 6, MySQL.
> 
> $success = db_query("INSERT INTO {user_profile_fields} (uid, username,
> id_center, telephone, street, city, distt, country, zip) VALUES
> ('$uid', '$username', '$idcenter', '$telephone', '$street', '$city',
> '$district', '$country', '$zip')");
>  if(!$success) {
>     // here I am using the $error = db_error();
>  }
> 
> Regards.
> -- 
> [ Drupal support list | http://lists.drupal.org/ ]



More information about the support mailing list