I'm building a small PHP forum that allows users to create posts and comment on them. I have a specific function that's supposed to display the number of replies on a post, that for some reason is only displaying zero. I also have a similar function that counts views and it's working perfectly, so I'm not sure what the issue is.
Here is the function code for the replies:
function countReplies($cid, $scid, $tid, $mysqli){
$select = mysqli_query($mysqli, "SELECT category_id, subcategory_id, topic_id FROM replies WHERE ".$cid." = category_id AND
".$scid." = subcategory_id AND ".$tid." = topic_id");
return mysqli_num_rows($select);
}
And here is how I called it:
<div class = "content">
disptopics($_GET['cid'], $_GET['scid'], $mysqli);
countReplies($_GET['cid'], $_GET['scid'], $_GET['tid'], $mysqli);
?>
</div>
I'm getting the following error:
Notice: Undefined index: tid in C:\xampp\htdocs(A)Book 2.0\Bootstrap\topics.php on line 56
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs(A)Book 2.0\Bootstrap\content_function.php on line 110
I'm pretty sure I defined variable tid, so any insight into this would be greatly appreciated.