In following code I have a fatal error:
function db_isValidStudent($loginCode) {
$dbConnection = get_my_dbConnection();
$sql = 'SELECT loginCode FROM Students WHERE loginCode = "'.DBi::$dbConnection->real_escape_string($loginCode).'" LIMIT 1';
if (!$dbResult = DBi::$dbConnection->query($sql)) {
echo DBi::$dbConnection->error;
return false;
}
if ($row = $dbResult->fetch_assoc()) {
return true;
}
}
Error Code:
Fatal error: Uncaught Error: Call to a member function real_escape_string() on null
I am looking forward to your answers and if you need more information please just ask.