Name

mysql_errno( )

Synopsis

unsigned int mysql_errno(MYSQL *mysql)

This returns the error number for the last function executed that failed. After a successfully executed function, 0 is returned from this function.

...
if(mysql_real_connect(mysql,host,"goofy",
                       password,database,0,NULL,0) =  = NULL)
   {
    printf("Error %d \n", mysql_errno(mysql));
    exit(EXIT FAILURE);
   }
...

In this example, the program is attempting to connect to the MySQL server with a user who is not in the mysql database.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.