Home How to get mysqli error in different environments?
 In my LOCAL/DEV environment, the mysqli query is performing OK. However, when I upload it on my WEBHOST environment, I got this error; Fatal error: Call to a member function bind_param() on a non-object in... Here is the code: global $mysqli;$stmt = $mysqli->prepare("SELECT id, description FROM tbl_page_answer_category WHERE cur_own_id = ?");$stmt->bind_param('i', $cur_id);$stmt->execute(); $stmt->bind_result($uid, $desc);  To check my query, I tried to execute the query via control panel phpmyadmin and the result is OK. If there are any lacking information, please tell me so that I can immediately provide. Your Common Sense 2# Your Common Sense Reply to 2016-10-03 20:48:59Z  First of all, always have this line before mysqli connect in all your environments: mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);  After that all mysql errors will be transferred into PHP exceptions. Uncaught exception, in turn, makes a PHP fatal error. Thus, in case of mysql error, you'll get a conventional PHP error, that will instantly make you aware of the error cause. A stack trace will lead you to the exact spot where error occurred. Note that you have to be able to see PHP errors in general. And here indeed goes the matter of different environments: on a live site you have to peek into error logs, so, settings have to be error_reporting(E_ALL); ini_set('display_errors',0); ini_set('log_errors',1);  while on a local development server it's ok to make errors on screen: error_reporting(E_ALL); ini_set('display_errors',1);  And a little list of what you should not: use error suppression operator (@) use die() or echo or any other function to print the error message on screen unconditionally. PHP can echo it all right already, no assistance required. test the query result manually (like if($result)) it just makes no sense. Either your query failed and you will already get the error exception, or it was all right and there is nothing to test use try..catch for echoing error message. Again PHP can do it better, way better.