Question

Is any way to call new mysqli($host, $user, $pass, $db_name) without printing the following errors?

Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'user'@'127.0.0.1' (using password: YES) in...

I don't like to ignore errors (@ or error_reporting(0)), i would like any other "better practice" way.

Was it helpful?

Solution

Well if you don't want errors to be printed - just tell PHP not to print them.
Configure PHP this way:

display_errors = 0
log_errors = 1

if you want to catch errors in some handler, you have to register it first.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top