By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 865 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Display server error

P: n/a
Is there a way, using PHP, to detect and display an error from a MySQL
server? Can I, by using error numbers or some similar method, create my own
error messages?

tia
Jun 29 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Bob Sanderson wrote:
Is there a way, using PHP, to detect and display an error from a MySQL
server? Can I, by using error numbers or some similar method, create
my own error messages?

Sure, you can suppress the error message by preprending an at sign "@" to
the mysql_* function call and get the error code from the string returned by
the mysql_error() function.

Afterwhich, you can use the list of error codes from the MySQL website to
map the error code to whatever you like.
JW
Jun 29 '06 #2

P: n/a
Janwillem Borleffs wrote:
Sure, you can suppress the error message by preprending an at sign
"@" to the mysql_* function call and get the error code from the
string returned by the mysql_error() function.


That should be: the mysql_errno() function.
JW
Jun 29 '06 #3

P: n/a
Bob Sanderson wrote:
Is there a way, using PHP, to detect and display an error from a MySQL
server? Can I, by using error numbers or some similar method, create my own
error messages?

tia


You can get the MySQL error number with mysql_errno() and the text with
mysql_error(). Then just display whatever text you wish.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 29 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.