PaXo Posted August 5, 2008 Share Posted August 5, 2008 <?php mysql_select_db('comments'); $query = "SELECT comments.comment_image, album.image_id FROM album, comments WHERE comment_image = image_id ORDER BY comment_id"; $result = mysql_query($query); while($row=mysql_fetch_array($result)) { $comment_id = $row['comment_id']; $comment_user = $row['comment_user']; $comment_email = $row['comment_email']; $comment_ip = $row['comment_ip']; $comment_content = $row['comment_content']; $comment_time = $row['comment_time']; $comment_date = $row['comment_date']; } echo $comment_user; echo $comment_content; ?> that is the code but it dosnt display the echos, there is information in the database but i dont have a clue why it wont display any help is much loved <3 Link to comment https://forums.phpfreaks.com/topic/118308-newbie-learning-d-comments-not-working/ Share on other sites More sharing options...
DeanWhitehouse Posted August 5, 2008 Share Posted August 5, 2008 put the echos in the while loop Link to comment https://forums.phpfreaks.com/topic/118308-newbie-learning-d-comments-not-working/#findComment-608821 Share on other sites More sharing options...
PaXo Posted August 5, 2008 Author Share Posted August 5, 2008 unfortunatly that didnt work, heres the updated code: <?php mysql_select_db('comments'); $query = "SELECT comments.comment_image, album.image_id FROM album, comments WHERE comment_image = image_id ORDER BY comment_id"; $result = mysql_query($query); while($row=mysql_fetch_array($result)) { $comment_id = $row['comment_id']; $comment_user = $row['comment_user']; $comment_email = $row['comment_email']; $comment_ip = $row['comment_ip']; $comment_content = $row['comment_content']; $comment_time = $row['comment_time']; $comment_date = $row['comment_date']; echo $comment_user; echo $comment_content; } ?> thanks for the quick reply though! Link to comment https://forums.phpfreaks.com/topic/118308-newbie-learning-d-comments-not-working/#findComment-608823 Share on other sites More sharing options...
budimir Posted August 5, 2008 Share Posted August 5, 2008 Try to echo your query first, and also put $result = mysql_query($query) or die (mysql_error()); And then you'll see what is happening!!!! Link to comment https://forums.phpfreaks.com/topic/118308-newbie-learning-d-comments-not-working/#findComment-608833 Share on other sites More sharing options...
PaXo Posted August 5, 2008 Author Share Posted August 5, 2008 this is the page output: SELECT comments.comment_image, album.image_id FROM album, comments WHERE comment_image = image_id ORDER BY comment_id Resource id #5 this is the updated code: <?php mysql_select_db('comments'); $query = "SELECT comments.comment_image, album.image_id FROM album, comments WHERE comment_image = image_id ORDER BY comment_id"; $result = mysql_query($query) or die (mysql_error()); echo $query; echo '<br>'; echo $result; while($row=mysql_fetch_array($result)) { $comment_id = $row['comment_id']; $comment_user = $row['comment_user']; $comment_email = $row['comment_email']; $comment_ip = $row['comment_ip']; $comment_content = $row['comment_content']; $comment_time = $row['comment_time']; $comment_date = $row['comment_date']; echo $comment_user; echo $comment_content; } ?> so it dosnt say anything is wrong with the query :/ (thatim aware of, code nos what resource id 5 is but ... thanks Link to comment https://forums.phpfreaks.com/topic/118308-newbie-learning-d-comments-not-working/#findComment-608841 Share on other sites More sharing options...
Ace Jon Posted August 5, 2008 Share Posted August 5, 2008 You've only selected 'comment_image' and 'image_id' form the table but you're trying to echo a whole bunch of other stuff. You have to SELECT everything you want in your $result array. Link to comment https://forums.phpfreaks.com/topic/118308-newbie-learning-d-comments-not-working/#findComment-608845 Share on other sites More sharing options...
PaXo Posted August 5, 2008 Author Share Posted August 5, 2008 fantastic mate! thanks very much <3 Link to comment https://forums.phpfreaks.com/topic/118308-newbie-learning-d-comments-not-working/#findComment-608855 Share on other sites More sharing options...
DeanWhitehouse Posted August 5, 2008 Share Posted August 5, 2008 this line $query = "SELECT comments.comment_image, album.image_id FROM album, comments WHERE comment_image = image_id ORDER BY comment_id"; shoud be $query = "SELECT * FROM album, comments WHERE comment_image = image_id ORDER BY comment_id"; Link to comment https://forums.phpfreaks.com/topic/118308-newbie-learning-d-comments-not-working/#findComment-608859 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.