I need your help with making comments show below my articles. At the moment i’m getting an Undefined Index error for all the mysql_fetch_array() elements returned.
Please where could my problem be coming from.?
Thanks for your time.
Comment Table
CREATE TABLE IF NOT EXISTS `comment` (
`comment_id` int(255) NOT NULL AUTO_ INCREMENT,
`article_id` int(255) NOT NULL,
`username` varchar(25) NOT NULL,
`comment_body` varchar(300) NOT NULL,
`comment_date` datetime NOT NULL,
PRIMARY KEY (`comment_id`),
UNIQUE KEY `comment_id` (`comment_ id`)
) ENGINE=InnoDB DEFAULT CHARSET= latin1 AUTO_INCREMENT=3 ;
About Table
CREATE TABLE IF NOT EXISTS `about` (
`about_id` int(255) NOT NULL,
`about_head` varchar(255) NOT NULL,
`about_content` varchar(400) NOT NULL,
`about_tags` varchar(25) NOT NULL,
`about_created` datetime NOT NULL,
`about_image` blob NOT NULL,
PRIMARY KEY (`about_id`),
UNIQUE KEY `about_id` (`about_id`)
) ENGINE=InnoDB DEFAULT CHARSET= latin1;
Display of Comments
$query6=mysql_query("SELECT c. username,c.comment_body,c.comment_ date
FROM comment AS c
INNER JOIN about AS a ON
c.article_id = a.about_id") or die
(mysql_error());
while ($comment = mysql_fetch_assoc ($query6)) {
echo "Comment: ";
$comment['comment_body'] ;
echo "<br/>" ;
echo "Date of Comment: ";
$comment['comment_date'] ; echo "<br/>" ;
echo "Commenter: ";
$comment['username'] ;
echo "<br/>" ;
}
UPDATE
I changed mysql_fetch_array to ,ysqo_fetch_assoc, but i’m still getting the same error….Undefined Index.
Looking at the way you (can’t) type, I’d bet at typo.
Anyway, do a
inside of the loop and see the actual array content.