I have a web application I wrote in PHP. I use a single Class to handle almost everything this app does. I predefine a few things before the class such as database name. What I was hoping for is that I could set a define for mysql_error().
So when I run a SQL query and add die() of error, I want it to ouput “An Error Has Occurred!” if the app is running in a production environment, but then I can change the 1 define from define(“DIEOUTPUT”, “An Error Has Occurred!”) to define(“DIEOUTPUT”, mysql_error());
My die() function looks like: die(DIEOUTPUT);
Is this possible to do?
No, that is not possible.
Instead, you could create your own version of
die():Note:
mysql_*functions to PDO or mysqli.die()(ormy_die()for that matter) on a real webpage is not too userfriendly, consider alternatives