mds1256 Posted January 1, 2013 Share Posted January 1, 2013 Hi Having a bit trouble understanding the best way to check if the SQL statement has worked. At the moment check the statement object if error then display bespoke error, if that passes then I check the statement object execute method and then if that fails show the same bespoke error for that form. so I have two if statements, which gets messy if I am calling multiple sql statements within the same php function as I end up with lots of nested if statements. Is there a better way of doing this? Quote Link to comment https://forums.phpfreaks.com/topic/272583-mysqli-prepared-statements-error-handling/ Share on other sites More sharing options...
Jessica Posted January 1, 2013 Share Posted January 1, 2013 Check out the link in my signature on debugging SQL. Quote Link to comment https://forums.phpfreaks.com/topic/272583-mysqli-prepared-statements-error-handling/#findComment-1402604 Share on other sites More sharing options...
PFMaBiSmAd Posted January 1, 2013 Share Posted January 1, 2013 If you have a block of code that can fail at a number of points, you can use exceptions with a try/catch block, which is essentially an 'on error, fall-though to the catch' statement. Quote Link to comment https://forums.phpfreaks.com/topic/272583-mysqli-prepared-statements-error-handling/#findComment-1402614 Share on other sites More sharing options...
mds1256 Posted January 4, 2013 Author Share Posted January 4, 2013 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/272583-mysqli-prepared-statements-error-handling/#findComment-1403210 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.