Kindly help me figuring this problem.
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...
$stmt = $mysqli->prepare("SELECT id, description FROM tbl_page_answer_category WHERE cur_own_id = ?");
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:
And a little list of what you should not:
echoor any other function to print the error message on screen unconditionally. PHP can echo it all right already, no assistance required.
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