So I have a function within a class to take the highest value based on another value but I'm getting a blank page.
I checked for bad syntax but there's none that the validator found and if I change it to header("Location: https://facebook.com")
it will go to the site so it seems the function is working. However I am not getting my variable back.
My connections and everything else are fine as my other functions in this class return what I want.
class FORUM
{
private $forum;
function __construct($DBFORUM_con)
{
$this->db = $DBFORUM_con;
}
public function addCount($id)
{
try
{
$stmt = $this->db->prepare("SELECT MAX(a_id) AS Maxa_id FROM forum_answer WHERE question_id = :id");
$stmt->execute(array(':id'=>$id));
$userRow = $stmt->fetch(PDO::FETCH_ASSOC);
if ($stmt->rowCount() > 0)
{
$Max_id = $userRow['Maxa_id'] + 1;
return $Max_id;
}
else {
$Max_id = 1;
return $Max_id;
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
}
Then in my page that processes the form:
//require class
$id = $_POST['id'];
if ($forum->addCount($id))
{
echo $Max_id;
}
else
{
echo $Max_id;
}