views:

53

answers:

3

Can any one Explain the difference mysql_errno and mysql_error ?

Thanks in advance

+7  A: 

mysql_errno returns the error code, while mysql_error returns the error text...

Macmade
+1 nothing more to say really. :)
Pekka
Correct answer yet there is another thing worth mentioning: The last error is reset with most of the mysql_* functions and therefore a programmer should get this error before calling another mysql_* function.
Poni
Hi both displaying the same thing only for example :when i use mysql_errno or mysql_error..1049: Unknown database 'nonexistentdb'1146: Table 'kossu.nonexistenttable' doesn't existthen whats the difference in both these
annamalaicse
@annamalaicse: mysql_error() and mysql_errno() _return_ a value, they do not output it automagically. But e.g. mysql_query() raises a php warning with the same text mysql_error() would return. Your error_reporting and display_errors settings probably cause the output you've described.
VolkerK
A: 

Are you saying the functions of php ?

mysql_errno returns the number of the error,

and mysql_error returns the text of the error.

You can easily find the difference in http://www.php.net/manual/en/function.mysql-errno.php

A: 
 string mysql_error  ([  resource $link_identifier  ] )

Returns the error text from the last MySQL function. Errors coming back from the MySQL database backend no longer issue warnings. Instead, use mysql_error() to retrieve the error text. Note that this function only returns the error text from the most recently executed MySQL function (not including mysql_error() and mysql_errno()), so if you want to use it, make sure you check the value before calling another MySQL function.

mysql_errno is the number of the error

Hi both displaying the same thing only for example :when i use mysql_errno or mysql_error..1049: Unknown database 'nonexistentdb'1146: Table 'kossu.nonexistenttable' doesn't existthen whats the difference in both these
annamalaicse