teynon Posted July 20, 2011 Share Posted July 20, 2011 Oops, you're missing a comma after $comment. $sql="INSERT INTO comments (name, `comment`, date_added) VALUES('$name', '$comment', '$date_added' ) "; Quote Link to comment Share on other sites More sharing options...
chandler Posted July 20, 2011 Author Share Posted July 20, 2011 Ok it's getting into the db now, but its not printing to the page, db looks like this Full Texts comment_id comment date_added page_id name Edit Delete 1 2011-07-20 18:47:56 0 Stephen Downs Edit Delete 2 test 0000-00-00 00:00:00 0 john doe Edit Delete 3 test 2 0000-00-00 00:00:00 0 john doe Quote Link to comment Share on other sites More sharing options...
teynon Posted July 20, 2011 Share Posted July 20, 2011 Your select statement is searching for a page id of 1 whereas you are inserting the fields with a page_id of 0. Quote Link to comment Share on other sites More sharing options...
chandler Posted July 20, 2011 Author Share Posted July 20, 2011 I tried changing that to, still nothing echoing $result = mysql_query("SELECT `comment`, name, comment_id, date_added FROM comments c JOIN pages p ON p.page_id = c.page_id WHERE c.page_id = 0 ORDER BY c.date_added") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
teynon Posted July 21, 2011 Share Posted July 21, 2011 My assumption is pages table has nothing with ID 0. You'll need to update the database to have the id's as 1. Not trying to be rude here, but this is some basic troubleshooting. You need to look at the database via PHPMyAdmin and try running the queries and see what they return. If they don't return, you need to modify your query or look at your data to understand why it is not returning anything. Quote Link to comment Share on other sites More sharing options...
TeNDoLLA Posted July 21, 2011 Share Posted July 21, 2011 Yes, when adding the new comments you have to fetch the table id from somewhere (maybe link or something). This will be the id of the page the comment is related to. And when inserting new comment you insert this page id also in the comments table. Quote Link to comment Share on other sites More sharing options...
chandler Posted July 21, 2011 Author Share Posted July 21, 2011 Ok thanks I will look into that. Thank you for all your help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.