IMO die() should only be used in the context for routes that should *NOT* occur in production environment, (ie. something with the program isn't operating properly and needs to stop)Christopher wrote:I it surprising how often I see PHP code that does not follow basic Structured Programming block structures instead of die().
A SQL query should be well formatted and checked for data to be used so that even if it returns nothing, the query doesn't actually fail. If something was missing to begin with that needs to go into the query, then the query shouldn't even get executed.
One thing I would suggest adding to Christopher's code if you go that route would be to add the line number to the error message, as it makes it much easier to locate
Code: Select all
$errormsg = "LINE=".__LINE__.", SQL=$XStock_rsUpd, ERROR=" . mysql_error();