Junior Spellweaver
- Joined
- Dec 29, 2015
- Messages
- 111
- Reaction score
- 75
Hey guys. It's me again.
I'm currently working on some new stuff for myself. And I got a really big problem.
I look if the table have an value, if the table don't have a value, then echo "n0 p0s7s h3r3".
But he skips all the time the if-loop and go into the else-loop. But the text 'n0 [...]' will display.
My Code:
Error:
I'm currently working on some new stuff for myself. And I got a really big problem.
I look if the table have an value, if the table don't have a value, then echo "n0 p0s7s h3r3".
But he skips all the time the if-loop and go into the else-loop. But the text 'n0 [...]' will display.
My Code:
Code:
public function getLastPostFromCat($subID) {
$subID = $this->Database()->escape(htmlspecialchars($subID));
$threadStmt = $this->Database()->getCon()->query("SELECT * FROM forum_threads WHERE subID = ".$subID." ORDER BY forumID DESC LIMIT 1");
if($threadStmt->rowCount() == 0) {
echo "No posts here";
} else {
$thread = $threadStmt->fetchObject();
$postStmt = $this->Database()->getCon()->query("SELECT userID, forumID FROM forum_posts WHERE forumID = ".$thread->forumID);
return $postStmt->fetchObject();
}
}
Code:
public function getThreadByID($id) {
$id = $this->Database()->escape($id);
$stmt = $this->Database()->select('*')->from('forum_threads')->where("forumID = ".$id);
if($stmt->row() == 0) {
//return nothing
} else {
return $stmt->get();
}
}
Code:
<a href="/thread/december-and-january-update-495/"><?= htmlspecialchars($this->ForumThreads->getThreadByID($this->ForumPosts->getLastPostFromCat($sub['subID'])->forumID)->forumTitle); ?></a>
Error:
Code:
[URL="http://localhost/thread/december-and-january-update-495/"]No posts hereError: 8
Message: Trying to get property of non-object
File: C:\xampp\htdocs\application\views\Home\Home.tpl
Line: 21[/URL]