No, I'm not sure how I can pass that value. Here's my code:
This is the story.php page. This lists all of the categories and stories. No errors on this page
<?php>
require_once("connect.php");
?>
<?php
// Selects the fields that will be displayed
$query="SELECT news_ID,news_category_ID,news_title,news_story from news WHERE news_category_ID=1 ORDER BY news_ID DESC";
$result=mysql_query($query,$connect);
// This formats the table
echo "<table width=200, border=1, align='center'>\n";
echo "<tr><td bgcolor='red'>Sports</td></tr>";
// This writes the data that has been selected
for($i=0;$i<mysql_num_rows($result);$i++){
list($news_ID,$news_category_ID,$news_title)=mysql_fetch_row($result);
echo "<tr><td><a href='showstory.php?news_ID=$news_ID&news_category_ID=$news_category_ID'>$news_title</a></td>\n";
}
// This closes the table
echo "</tr><tr><td bgcolor='red'> </td></tr>\n";
echo "</table>\n";
// Selects the fields that will be displayed
$query="SELECT news_ID,news_category_ID,news_title,news_story from news WHERE news_category_ID=2 ORDER BY news_ID DESC";
$result=mysql_query($query,$connect);
// This formats the table
echo "<table width=200, border=1, align='center'>\n";
echo "<tr><td bgcolor='red'>Entertainment</td></tr>";
// This writes the data that has been selected
for($i=0;$i<mysql_num_rows($result);$i++){
list($news_ID,$news_category_ID,$news_title)=mysql_fetch_row($result);
echo "<tr><td><a href='showstory.php?news_ID=$news_ID&news_category_ID=$news_category_ID'>$news_title</a></td>\n";
}
// This closes the table
echo "</tr><tr><td bgcolor='red'> </td></tr></table>\n";
// Selects the fields that will be displayed
$query="SELECT news_ID,news_category_ID,news_title,news_story from news WHERE news_category_ID=3 ORDER BY news_ID DESC";
$result=mysql_query($query,$connect);
// This formats the table
echo "<table width=200, border=1, align='center'>\n";
echo "<tr><td bgcolor='red'>News</td></tr>";
// This writes the data that has been selected
for($i=0;$i<mysql_num_rows($result);$i++){
list($news_ID,$news_category_ID,$news_title)=mysql_fetch_row($result);
echo "<tr><td><a href='showstory.php?news_ID=$news_ID&news_category_ID=$news_category_ID'>$news_title</a></td>\n";
}
// This closes the table
echo "</tr><tr><td bgcolor='red'> </td></tr>\n";
echo "</table>\n";
mysql_close($connect);
?>
<br>
<center><a href="addnews.php">Add a story</a></center>
This is my showstory.php page. It properly displays the correct story but when I try to enter a comment I get this error message.
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\apache\htdocs\newsboard\showstory.php on line 9
<?php>
require_once("connect.php");
?>
<?php
// Selects the fields that will be displayed
$query1="SELECT news_title,news_story FROM news WHERE news_ID=$news_ID";
$result1=mysql_query($query1,$connect);
list($news_title,$news_story)=mysql_fetch_row($result1);
echo "$news_title <br> $news_story";
echo "<br><br>";
echo "Visitors comments <br><br>";
// Selects the comments that will be displayed
$query2="SELECT comments_Name,comments_Comment FROM comments";
$result2=mysql_query($query2,$connect);
list($comments_Name,$comments_Comment)=mysql_fetch_row($result2);
echo "$comments_Name <br> $comments_Comment";
//mysql_close($connect);
?>
<table>
<form action="showstory.php" method=post>
<font size=2>
<tr><td>Name</td> <td><input type=text maxlength=20 Name="Array[comments_Name]" size=20></td></tr>
<tr><td>Comment</td><td><textarea name="Array[comments_Comment]" rows=3 cols=20></textarea></td></tr>
<tr><td><input type=submit name="submit" value="Submit"></td>
<td><input type=Reset name="reset" value="Reset"></td></tr>
</font>
</form>
</table>
<?php
// This receives and handles the data generated from the form"
$Array["comments_Name"] = trim($Array["comments_Name"]);
$Array["comments_Comment"] = trim($Array["comments_Comment"]);
$Array["comments_news_ID"] = trim($Array["comments_news_ID"]);
$DBName = "newsboard";
$TableName = "comments";
$query = "INSERT into comments values ('0', '$Array[comments_Name]', '$Array[comments_Comment]', '$Array[comments_news_ID]')";
mysql_close($connect);
?>