I am attempting to prepare my sql statement however I am getting an error thrown that I cannot discern.
Uncaught Error: Call to a member function fetch_assoc() on bool
I have this error reporting on at the top of my file:
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
Section that fails:
$alreadyHasJob = "SELECT IF( EXISTS(SELECT `id_number` FROM `agent_client_jobs` WHERE `facilitator` = ? and `key` != ? and ? <= `start_TS` AND `start_TS` <= ?), 'YES', 'NO') as 'check'";
$alreadyHasJobPrepared = $MySQL_Read->prepare($alreadyHasJob);
$alreadyHasJobPrepared->bind_param('ssii', $facId, $jobKey, $startOfDate, $endOfDate);
$alreadyHasJobPrepared->execute();
$alreadyHasJobResult = $facilitatorsPrepared->get_result();
$alreadyHasJobData = $alreadyHasJobResult->fetch_assoc();
I have similar statements before and after this one on the same connection and they all pass correctly. I have already checked the types of the binded parameters, substituted my values and run it on phpmyadmin and it runs correctly. It works if I don’t prepare the statement however I want it prepared correctly.
>Solution :
What is your $facilitatorsPrepared and where does it come from?