How can I check if a query went wrong instead of showing errors to users (containing database info which is unsafe).
Let's say I have such situation where my paging class takes a URI segment to show page
example.com/page/uri_segment
. If someone write it like this example.com/page/bla_bla_bla
I get an error that shows information about my database.
How can I handle this?
You can configure your CI log file by going to the config. php file in your applications/config directory and set value to $config['log_threshold'] . For a live site, you'll usually only enable Errors (1) to be logged otherwise your log files will fill up very fast.
By default, CodeIgniter displays all PHP errors. You might wish to change this behavior once your development is complete. You'll find the error_reporting() function located at the top of your main index.
You can try this
$this->db->error();
, this will get you the ErrorCode & Errormessage in array format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With