Hello,
I had it the other day but now altered the code for my real database and it stopped working.
Here is the first page which lists the 10 most recent news stories:
<?php
require ('get_connected.php');
$sql = mysql_query ("SELECT title, story_id FROM news ORDER BY story_id DESC LIMIT 0, 10");
while ($row = mysql_fetch_assoc($sql)){
echo "<a href='view.php?id={$row['story_id']}'>" . ucwords(strtolower($row['title'])) . "</a><br>";
}
?>
And here is the page that should be displaying the news story based on story_id selected by the user.
<?php
require ('get_connected.php');
if (isset($_GET['id'])) {
$sql = "SELECT title, story_date, body FROM news WHERE story_id = '" . mysql_real_escape_string($_GET['story_id']) . "'";
if ($result = mysql_query($sql)) {
if (mysql_num_rows($result)) {
$row = mysql_fetch_assoc($result);
echo "<h1>" . $row['title'] . "</h1><br>";
echo $row['story_date'];
echo $row['body'];
} else {
echo "Something is wrong!";
}
}
}
?>
The view.php page is echoing "Something is wrong!". I checked everything but can't put my finger on what I am doing wrong.
Any suggestions?
Thanks