Below I have a code where I am trying to run a query using mysqli.
if (isset($_POST['module']))
{
$query = "SELECT ModuleNo, ModuleName FROM Module WHERE ModuleId = ?";
$stmt = $mysqli->prepare($query); //line 99
$stmt->bind_param('s', $_POST['module'] );
if ( $stmt->execute() )
{
$stmt->bind_result($moduleno, $modulename);
$stmt->fetch();
}
}
Problem is that it is giving me these two undefined errors:
Notice: Undefined variable: mysqli in ... on line 99
Fatal error: Call to a member function prepare() on a non-object in ... on line 99
My question is what is causing the two errors in mysqli code as I don’t see a problem with the code I have compiled.
Make sure you’re setting
$mysqliproperly in your script.