Nothematic
10-29-2014, 09:43 PM
Hi all,
I'm trying to display every post in a specified thread on an external page. I'm using this (awful) code but I'm not able to get it to display anything. Anyone got any ideas as to why? I'm not the best when it comes to PHP and MySQL. Thanks.
<?php
$username = *FORUM_DB_USERNAME*
$password = *FORUM_DB_PASSWORD*
$forumcon = new PDO('mysql:host=localhost;dbname=*FORUM_DB_NAME*', $username, $password);
$posts = "SELECT `title`, `pagetext` FROM `post` WHERE `threadid=2"; //specified threadid 2
$result = $forumcon->prepare($posts);
$result->execute();
while($row = $result-fetch()) {
echo "<b>" . htmlspecialchars($row['title']) . "</b>";
echo "<hr />";
echo htmlspecialchars($row['pagetext']);
echo "<br /><br />";
}
?>
I'm trying to display every post in a specified thread on an external page. I'm using this (awful) code but I'm not able to get it to display anything. Anyone got any ideas as to why? I'm not the best when it comes to PHP and MySQL. Thanks.
<?php
$username = *FORUM_DB_USERNAME*
$password = *FORUM_DB_PASSWORD*
$forumcon = new PDO('mysql:host=localhost;dbname=*FORUM_DB_NAME*', $username, $password);
$posts = "SELECT `title`, `pagetext` FROM `post` WHERE `threadid=2"; //specified threadid 2
$result = $forumcon->prepare($posts);
$result->execute();
while($row = $result-fetch()) {
echo "<b>" . htmlspecialchars($row['title']) . "</b>";
echo "<hr />";
echo htmlspecialchars($row['pagetext']);
echo "<br /><br />";
}
?>