$query = SELECT topic_title, topic_id, FROM_UNIXTIME(topic_time,"%W the %D %M @ %r") AS Topic_Date, post_text, username FROM (phpbb_topics RIGHT JOIN phpbb_posts_text ON topic_first_post_id=post_id) RIGHT JOIN phpbb_users ON topic_poster=(user_id WHERE forum_id=6) ORDER BY topic_time;
My eyes just arnt finding the error... i think
lil help please
$query = "SELECT topic_title, topic_id, FROM_UNIXTIME(topic_time,'%W the %D %M @ %r') AS Topic_Date, post_text, username FROM (phpbb_topics RIGHT JOIN phpbb_posts_text ON topic_first_post_id=post_id) RIGHT JOIN phpbb_users ON topic_poster=(user_id WHERE forum_id=6) ORDER BY topic_time";
$query = "SELECT topic_title, topic_id, FROM_UNIXTIME(topic_time,'%W the %D %M @ %r') AS Topic_Date, post_text, username FROM (phpbb_topics RIGHT JOIN phpbb_posts_text ON topic_first_post_id=post_id) RIGHT JOIN phpbb_users ON topic_poster=(user_id WHERE forum_id=6) ORDER BY topic_time;";
Ahhh yes, ... still this gives me a different error now
SELECT topic_title, topic_id, FROM_UNIXTIME(topic_time,'%W the %D %M @ %r') AS Topic_Date, post_text, username FROM (phpbb_topics RIGHT JOIN phpbb_posts_text ON topic_first_post_id=post_id) RIGHT JOIN phpbb_users ON topic_poster=(user_id WHERE forum_id=6) ORDER BY topic_time: 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 'WHERE forum_id=6) ORDER BY topic_time' at line 1
This is MySQL 4.0.13 im using (well my host is using) ...
Something small causing this or am i gonna really have to rewrite the entire script?
$query = "SELECT topic_title, topic_id, FROM_UNIXTIME(topic_time,'%W the %D %M @ %r') AS Topic_Date, post_text, username FROM (phpbb_topics RIGHT JOIN phpbb_posts_text ON topic_first_post_id=post_id) RIGHT JOIN phpbb_users ON topic_poster=(user_id WHERE forum_id=6) ORDER BY topic_time";
the extra ; was inside your final "
I don't think you need it
SELECT topic_title, topic_id,
FROM_UNIXTIME(topic_time,'%W the %D %M @ %r') AS Topic_Date,
post_text, username
FROM phpbb_topics
RIGHT JOIN phpbb_posts_text ON topic_first_post_id=post_id
RIGHT JOIN phpbb_users ON topic_poster=user_id
WHERE forum_id=6
ORDER BY topic_time;
You had some extra parentheses around the right joins. The first one should have been ok, but the second one had funny parenthesis around the join condition and the where clause.
Regarding the semi-colon phpScott noticed: you should always terminate your SQL statements (that means adding the semi-colon). This makes it harder for attackers to interject additional sql into the query, especially as MySQL disgards anything after the first unquoted semi-colon.
SELECT topic_title, topic_id,
FROM_UNIXTIME(topic_time,'%W the %D %M @ %r') AS Topic_Date,
post_text
FROM phpbb_topics
RIGHT JOIN phpbb_posts_text ON topic_first_post_id=post_id
JOIN phpbb_users
WHERE user_id=topic_poster AND forum_id=6
ORDER BY topic_time;
SELECT topic_title, topic_id,
FROM_UNIXTIME(topic_time,'%W the %D %M @ %r') AS Topic_Date,
post_text, username
FROM phpbb_topics
RIGHT JOIN phpbb_posts_text ON topic_first_post_id=post_id
JOIN phpbb_users
WHERE user_id=topic_poster AND forum_id=6
ORDER BY topic_time;