您可以自定义mysql_error重复错误消息吗? [英] Can you customize a mysql_error duplicate error message?
问题描述
我收到键名'username'的重复条目'blah'"错误消息,但我希望它显示为此用户名已存在".
有可能吗?如果是这样,我将在哪里以及如何去改变它?
我正在使用PHP,MySQL和phpmyadmin.
对不起,我很笨拙.预先感谢.
$result = mysql_query('... query that produces duplicate key error ...');
if ($result === FALSE) {
if (mysql_errno() == 1022) {
die("Username already exists");
} else {
die(mysql_error());
}
}
此处记录了错误代码: http: //dev.mysql.com/doc/refman//5.5/zh-CN/error-messages-server.html ,如果需要,您可以编写自己的自定义错误处理程序以输出"nicer"错误消息. /p>
I'm getting a "Duplicate entry 'blah' for key 'username'" error message, but I would LOVE for it to read "This username already exists".
Is that possible? If so, where and how would I go about changing that?
I'm using PHP, MySQL and phpmyadmin.
Sorry for my noobishness. Thanks in advance.
$result = mysql_query('... query that produces duplicate key error ...');
if ($result === FALSE) {
if (mysql_errno() == 1022) {
die("Username already exists");
} else {
die(mysql_error());
}
}
The error codes are documented here: http://dev.mysql.com/doc/refman//5.5/en/error-messages-server.html and you can write your own custom error handler to output 'nicer' error messages if you so desire.
这篇关于您可以自定义mysql_error重复错误消息吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!