I am supposed to design an exam server system and I keep getting errors while I am trying to prepare the statement using mysqli's prepare function. I am using php to connect to sql represented by the $conn variable(it does connect to the DB), and I have tried the same exact statements in mysql workbench and it works fine. Here is the code I have written:
$stmtTempTable = $conn->prepare("CREATE TEMPORARY TABLE front_action_temp
SELECT * FROM front_action
WHERE time_offset > 0");
$stmt = $conn->prepare("SELECT event_name, status, day_of_week, week_of_year, event_year, start_time, time(start_time +
time_offset) as end_time, machine_group
FROM front_weekly
LEFT JOIN front_event ON front_weekly.event_id=front_event.event_id
LEFT JOIN front_daily ON front_event.event_id=front_daily.event_id
LEFT JOIN front_group ON front_daily.group_id=front_group.group_id
LEFT JOIN front_action_temp ON front_action_temp.event_id=front_event.event_id
WHERE day_of_week=? and week_of_year=? and event_year=?");
if ($stmt === false){
die('Unable to execute');
} else {
$stmt->bind_param('sss', $dayOfWeek, $weekNumber, $year);
$stmt->execute();
}
I keep getting false for $stmt. Any ideas why?