Why isn't the code displaying database content???
Posted: Sun Jul 23, 2006 9:01 pm
My code is displaying the date_entered and not the article. Can someone please tell me why? Thanks in advance. 
Here is the code for the displaying the content:
And here is the code for adding the content to the database:
Here is the code for the displaying the content:
Code: Select all
require "config2.php";
$article_id = $_GET['article_id'];
$article = mysql_real_escape_string($_POST['article']);
$query = "SELECT * FROM articles";
if ($r = mysql_query ($query)) {
$str = "";
while ($row = mysql_fetch_array ($r)) {
$str .= '<p>'. $row['date_entered'] . '<br />' . $row['article'] . '<br />
<a href="modify_article.php?id="'. $_GET['article_id'] .'">Modify</a>
<a href="delete_article.php?id="'. $_GET['article_id'] .'">Delete</a>
</p>';
}
if($str==="")
{
echo 'No entries to be displayed. <a href="diary.php">Click here</a> to return to the main page.';
} else {
echo $str;
}
}
} else {
print "You are not logged in. Please <a href=login.php>click here</a> to login.";
}
mysql_close();Code: Select all
require "config2.php";
$article_id = $_GET['article_id'];
$article = mysql_real_escape_string($_POST['article']);
$date_entered = date("j F, Y");
$insert = "INSERT INTO articles (`id`, `article_id`, `article`, `date_entered`) VALUES
(0, '$article_id', '$article', '$date_entered')" or die ('<p>Could not insert data into the table.</p>');
if (mysql_query ($insert)) {
print '<p>The diary entry has been added. <a href="view_articles.php">Click here</a> to continue.</p>';
} else {
print "<p>Could not add the entry because: <b>" . mysql_error() .
"</b>. The query was $query.</p>";
}
mysql_close();