I am using the same code again at another site, however I called my "entry" field "issue". But I keep getting the following error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.../public_html/.../archive.php on line 7
Here's my code:
CODE
<?
include("archive/admin.php");
include("head.inc");
$result = mysql_query("SELECT FROM_UNIXTIME( timestamp, '%Y' ) AS get_year, COUNT(*) AS issues FROM $table GROUP BY get_year");
while ($row = mysql_fetch_array($result)) {
$get_year = $row["get_year"];
$issues = $row["issues"];
echo "<h1>issues from $get_year ($issues)</h1>\n";
$result2 = mysql_query("SELECT timestamp, issueID, title FROM $table WHERE FROM_UNIXTIME( timestamp, '%Y' ) = $get_year ORDER BY timestamp DESC");
?>
<table cellspacing="5" cellpadding="0">
<?
while ($row2 = mysql_fetch_array($result2)) {
$date = date("M y",$row2["timestamp"]);
$issueID = $row2["issueID"];
$title = $row2["title"];
echo "<tr><td>$date</td><td><a href=\"issue.php?id=$issueID\">$title</a></td></tr>";
}
echo "</table>";
}
include("foot.inc");
?>
include("archive/admin.php");
include("head.inc");
$result = mysql_query("SELECT FROM_UNIXTIME( timestamp, '%Y' ) AS get_year, COUNT(*) AS issues FROM $table GROUP BY get_year");
while ($row = mysql_fetch_array($result)) {
$get_year = $row["get_year"];
$issues = $row["issues"];
echo "<h1>issues from $get_year ($issues)</h1>\n";
$result2 = mysql_query("SELECT timestamp, issueID, title FROM $table WHERE FROM_UNIXTIME( timestamp, '%Y' ) = $get_year ORDER BY timestamp DESC");
?>
<table cellspacing="5" cellpadding="0">
<?
while ($row2 = mysql_fetch_array($result2)) {
$date = date("M y",$row2["timestamp"]);
$issueID = $row2["issueID"];
$title = $row2["title"];
echo "<tr><td>$date</td><td><a href=\"issue.php?id=$issueID\">$title</a></td></tr>";
}
echo "</table>";
}
include("foot.inc");
?>
I found this previous entry and tried to replace COUNT(*) with both COUNT(title) and COUNT(issue) but I continue to get the same error message.
For some reason it's just not getting anything in the $result query on live 5 and I don't know why.
help?