mysql_errno()
unsigned int mysql_errno(MYSQL *mysql)
This function returns the error number for the last function that was run if it failed to execute. If the last function executed was successful, a value of 0 is returned by this function. Here is an example:
...
if(mysql_real_connect(mysql,host,"goofy",
password,database,0,NULL,0) == NULL)
{
printf("Error %d \n", mysql_errno(mysql));
return 1;
}
...The program here is attempting to connect to the MySQL server
for a user who is not in the mysql database.