mysql_error()
char *mysql_error(MYSQL *mysql)
This function returns the error message for the last function that was run if it failed to execute. If the last function executed was successful, an empty string is returned by this function. Here is an example:
...
if(!mysql_real_connect(mysql,host,"goofy",
password,database,0,NULL,0))
{
printf("Error Message: %s \n", mysql_error(mysql));
return 1;
}
...The program here is attempting to connect to the MySQL server
with a user who is not in the mysql
database.