-2

So I've just been doing this using die. I don't really want to print out mysql and php errors on the page for the user to see... maybe send the error to a log file? How to handle the rest of the page if a mysqli_query fails for some reason?

if(!mysqli_query($db, $q))
    die();

Thanks.

Kaiwen
  • 94
  • 7

1 Answers1

1

You can log the errors to the error_log file

if(!mysqli_query($db, $q)) {

//error
error_log('There is an issue with this Query on live server. The Query is '.$q);    
}

You can also send a mail to yourself as well. This would be a better option as you would actually know that an error has occured on the live server. The last thing you want is clients calling you to fix errors. Its better you have a headstart

Rotimi
  • 4,783
  • 4
  • 18
  • 27