Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 37.8Mb
PDF (A4) - 37.8Mb
PDF (RPM) - 36.4Mb
HTML Download (TGZ) - 9.9Mb
HTML Download (Zip) - 9.9Mb
HTML Download (RPM) - 8.6Mb
Man Pages (TGZ) - 209.5Kb
Man Pages (Zip) - 318.7Kb
Info (Gzip) - 3.5Mb
Info (Zip) - 3.5Mb
Excerpts from this Manual mysql_error()

const char *mysql_error(MYSQL *mysql)


For the connection specified by mysql, mysql_error() returns a null-terminated string containing the error message for the most recently invoked API function that failed. If a function did not fail, the return value of mysql_error() may be the previous error or an empty string to indicate no error.

A rule of thumb is that all functions that have to ask the server for information reset mysql_error() if they succeed.

For functions that reset mysql_error(), either of these two tests can be used to check for an error:

  // an error occurred

  // an error occurred

The language of the client error messages may be changed by recompiling the MySQL client library. You can choose error messages in several different languages. See Section 10.11, “Setting the Error Message Language”.

Return Values

A null-terminated character string that describes the error. An empty string if no error occurred.



User Comments
  Posted by Ding on November 16, 2005
I have use this function on an example in mysql_warning_count()
  Posted by Joerg Schmitz-Linneweber on November 2, 2006
Please keep in mind that the return value of this function won't be persistent over multiple API calls. If you need to keep the error message over some time, you'll have to copy it "away". (BTW How is the allocated space of the original message freed?)

Sign Up Login You must be logged in to post a comment.