Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9086341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:27:56+00:00 2026-06-16T21:27:56+00:00

I am having issues with the <?php //create_cat.php include ‘connect.php’; include ‘header.php’; $sql =

  • 0

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&prime;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).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:27:57+00:00Added an answer on June 16, 2026 at 9:27 pm

    you have extra comma before the from clause to remove,

    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   // << remove extra comma here
    FROM
            posts
    LEFT JOIN
            users
    ON
            posts.post_by = users.user_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having issues with connecting to MySQL 5.5.8 from PHP 5.3.5 (WAMP install). I'm
I'm having some issues returning values from a server with php + mysql. This
I'm having issues with the functions.php file with variables $prev_dept = 0; $comment_count =
I am trying to get php's namespace technique down but having some issues here:
I'm trying to create a calendar class in php and am having issues returning
I am having some issues editing my code to use the PHP foreach function.
I'm having issues with getting data from an AJAX file, I am trying to
I'm trying to setup the PHP mysqlnd_ms extension and I'm having some issues. So
I am having some issues trying to create page navigation using php, I have
having some issues with getting the output from an array. I've looked around and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.