Jump to content

newbie learning :D - comments not working


PaXo

Recommended Posts

<?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

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!

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 :)

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";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.