Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check codeigniter query errors instead of showing them to the user

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?

like image 937
baranq Avatar asked Jul 06 '11 16:07

baranq


People also ask

How do you show CI error?

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.

Where can we see log messages and error messages in CodeIgniter?

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.


1 Answers

You can try this $this->db->error(); , this will get you the ErrorCode & Errormessage in array format.

like image 102
sushil Avatar answered Nov 15 '22 19:11

sushil