I am having issues with the
<?php
//create_cat.php
include 'connect.php';
include 'header.php';
$sql = "SELECT
topic_id,
topic_subject,
topic_cat
FROM
topics
WHERE
topics.topic_id = " . mysql_real_escape_string($_GET['id']);
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
echo '<a href="index.php">Nexus</a> > <a href="category.php?id=' . $row['topic_cat'] . '">Category will go here.</a> > <a href="topic.php?id=' . $row['topic_id'] . '">' . $row['topic_subject'] . '</a><br>';
if(!$result)
{
echo 'The topic could not be displayed, please try again later.';
}
else
{
if(mysql_num_rows($result) == 0)
{
echo 'This topic doesn′t exist.';
}
else
{
{
//display post data
echo '<table class="topic">
<tr>
<th colspan="2">' . $row['topic_subject'] . '</th>
</tr>';
//fetch the posts from the database
$posts_sql = "SELECT
posts.post_topic,
posts.post_content,
posts.post_date,
posts.post_by,
posts.post_id,
users.user_id,
users.user_name,
users.user_title,
FROM
posts
LEFT JOIN
users
ON
posts.post_by = users.user_id
WHERE
posts.post_topic = " . mysql_real_escape_string($_GET['id']);
$posts_result = mysql_query($posts_sql);
if(!$posts_result)
{
echo '<tr><td>The posts could not be displayed, please try again later.</tr></td></table>';
}
else
{
while($posts_row = mysql_fetch_assoc($posts_result))
{
echo '<tr class="topic-post">
<td class="user-post"><div id="user">
<b>' . $posts_row['user_name'] . '</b><br/>' . $posts_row['user_title'] . '</div><br/>' . date('m-d-Y h:ia', strtotime($posts_row['post_date'])) . '</td>
<td class="post-content">
<a name="postid=' . $posts_row['post_id'] . '"></a>
' . htmlentities(stripslashes($posts_row['post_content'])) . '</td>
</tr>';
}
}
if(!$_SESSION['signed_in'])
{
echo '<tr><td colspan=2>You must be <a href="signin.php">signed in</a> to reply. You can also <a href="signup.php">sign up</a> for an account.';
}
else
{
//show reply box
echo '<tr><td colspan="2"><h2>Reply:</h2><br />
<form method="post" action="reply.php?id=' . $row['topic_id'] . '">
<textarea name="reply-content"></textarea><br /><br />
<input id="button" type="submit" value="Submit reply" />
</form></td></tr>';
}
//finish the table
echo '</table>';
}
}
}
include 'footer.php';
?>
It says
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘FROM posts LEFT JOIN users ON posts.post_by = u’ at line 10
at the bottom (I added an echo mysql_error(); at the bottom). This is rather important as it is for forum software that other people actually use and it powers about 4 different things on my site (seems excessive, but all are temporarily hooked up to the same database, one is for active development of it, and the other is for the actual software).
you have extra comma before the
fromclause to remove,