0

Is there a way to get the mysql error string message when we only know the code number of the error, taken by mysql_errno() command?

3 Answers 3

1

You can get information about what sort of error fired (see e.g.: server error messages). But you cant associate the error code to the detail error message. So the mapping will give you the type of error which happened but:

mysql_error()

will always give more information in addition to mysql_errno.

Sign up to request clarification or add additional context in comments.

2 Comments

I see, at least can I get the type somehow?
You may get the type by reverse mapping the error code to the associated string template in the file share/errmsg.txt of your mysql distribution. Another option would be the evaluation of the logs if you have an associated timestamp.
1

There can be server or client errors.

See here: http://dev.mysql.com/doc/refman/5.0/en/error-handling.html

2 Comments

I mean server error ofcourse. But is there a command that returns the string message by the error number?
I don't know of a command for this. But you can put them in a table and based on the error no. take the string. Check also here: briandunning.com/error-codes/?source=MySQL
1

The command mysql_errno() doesn't just return a number, in most cases it is used hand in hands with mysql_error. You can use mysql_error to return the text of the error message from previous MySQL operation.

If you encounter a case where it doesn't return some text, refer this section in the Mysql-documentation: http://dev.mysql.com/doc/refman/5.5/en/error-handling.html

2 Comments

So I can get only the last error that happened and not a string of an error that happened sometime before, and I only know the number of this error?
Exactly. For that php would need kindof a library for all mysql errors, and that -at least from my perspective- ain't the purpose of php.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.