Before anyone comments, I'm learning PHP/MySQL so I am aware my code is subject to sql injection, once I have my system built my next step is learning about security, 1 step at a time... Now to my problem
I have a basic page that allows people to post like a forum, I have everything posting to the database correctly, when I view the topic page itself, I successfully JOINed the users table with topics to get the user information(username, avatar), but when I try the same code with topics changed to posts, I'm getting a Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in view_topic.php on line 36 error.
Here is the working code..
$id = $_GET['topic_id'];
$sql = "SELECT users.user_id, users.username, users.profile, topics.topic_id, topics.category, topics.sub_category, topics.topic_data,
topics.posted_by, topics.posted, topics.view
FROM `topics`
JOIN `users` on topics.posted_by = users.user_id WHERE topic_id='$id'";
Here is my posts code NOT WORKING
$sql2 = "SELECT users.user_id, users.username, users.profile, post_id, post_content, post_date, post_topic, post_by
FROM `posts`
JOIN `users` on posts.posted_by = users.user_id WHERE post_topic='$id'";