I would like to know whether it is possible to let PHPmyadmin give back custom error massages, for example on a duplicate key.
I.e. “The username already exists” instead of “Duplicate entry ‘testUsername’ for key 2”.
This is because I have to validate several forms, and I am aware I could do it with some lines of PHP, so i can give the user some meaningfull error messages.
But because there are primary keys etc. implemented in my database I thought it would be easier/better to just let the user see the actual database error message (albeit a custom instead of the non user-friendly default one).
What would you do in such as situation?
Mmmm… not really, at least not easily.
Duplicate entry ... for key Xis a native mySQL error message. There isn’t a string stored for this somewhere in phpMyAdmin’s settings that you can edit – it comes directly from the storage engine.You would have to dig into phpMyAdmin, find out where it outputs the engine’s error messages, and insert some code in there that checks for the current table, and replaces the message.
I dare say that’s going to be a lot more work than actually building a CRUD interface of your own – a shame really, because essentially, phpMyAdmin already has everything one needs and would otherwise be perfect for the job!