Please help me with this issue in my script. At the point of the INSERT query $article_id returns 0, while actually it is a value that is not 0 (1, 2, 3).
I have tried to echo out $article_id at various points of the code and it actually echoed out what i wanted. But once i tried to echo it after the
isset($_POST['submit']) it does not echo out anything.
I have also checked the type i declared in the MySQL table....int. But still insert 0 into the database.
Please where could the problem be?
Thank you for your time and patience.
$page_name = 'about';
$id = "";
if (isset($_GET['id']))
{
$id = $_GET['id'];
$past1 = mysql_query("SELECT *
FROM about
WHERE about_id = '".$id."' ");
$row = mysql_fetch_array($past1);
echo "<p>" .$row['about_head']."</p>";
echo $row['about_content'];
$article_id = $row['about_id'] ;
$query6 = mysql_query("SELECT c.comment_body, c.comment_date
FROM comment AS c
INNER JOIN about AS ac ON c.article_id = ac.about_id
WHERE c.article_id = '".$article_id."'
AND page_name = '".page_name."'");
while ($comment = mysql_fetch_assoc($query6))
{
echo "<b>Comment:</b> " . $comment['comment_body'] . "<br/>" ;
echo "<b>Date of Comment:</b> " . $comment['comment_date'];
echo "<br/>" ;
echo "</div>";
}
}
if (isset($_POST['submit']))
{
$comment_body = mysql_real_escape_string($_POST['comment_body']);
if (($comment_body == "")
{
echo "<div class=\"error\" >" ;
echo "One/More Empty Field";
echo "</div>";
}
else
{
$query = "INSERT INTO comment (comment_id, article_id, username, page_name,
comment_body, comment_date)
VALUES (NULL, '".$article_id."', '".$_SESSION['logged_username']."',
'".$page_name."', '".$comment_body."', NOW())";
mysql_query($query);
}
}