Hi,
Thanks for replying. I already have it set to the following in my sql_con() function which establishes connection to database:
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
My confusion is in my try block i try to check if a username exists on the users table and user ban list table, it then gets executed using execute(), now my confusion is why would i use an if statement around the execute() as shown in my code ?
I thought if the execute() failed it would be caught in the catch block, but seeing examples online i see people wrap the execute() in an if statement as illustrated in my code.
and back to my questions:
1) In example code, why is it i would use an if statement on execute() ? (if it failed to execute shouldn't it be caught in the catch block ? )
2) What could cause the execute to fail ?
3) and why if execute failed it would not be caught by catch block ?
I am confusing myself somewhere and am not quite getting it, hence my questions.
Basically anything caught in the catch block in example code is written to a log file, in example code in catch block i call my function ExceptionErrorHandler($e);, this function writes any error to file.
Hopefully i have explained better.
Thanks for trying to help.