My code is as follows, for an include which will grab links from my database, and sort them into categories as specified over two tables, "perch_links" and "perch_links_cat". The file can be seen included here.
<?
echo("<h4>Links</h4>\n");
echo("<h5>Categories</h5>\n");
echo("<center>\n");
$cat_query = "SELECT * FROM `perch_links_cat` ORDER BY `name` ASC";
$cat_result = mysql_query($cat_query);
$cat_num = mysql_numrows($cat_result);
$i1 = 0;
while($i1 < $cat_num) {
$cat_name = mysql_result($cat_result,$i1,"name");
$cat_id = mysql_result($cat_result,$i1,"index");
echo(" <a href=\"#".$cat_id."\">".$cat_name."</a> \n");
++$i1;
}
echo("<hr></center>\n");
$i2 = 0;
while($i2 < $cat_num) {
$cat_name = mysql_result($cat_result,$i2,"name");
$cat_id = mysql_result($cat_result,$i2,"index");
echo("<h5><a name=\"".$cat_id."\">".$cat_name."</a></h5>\n");
$link_query = "SELECT * FROM `perch_links` WHERE `category` LIKE `".$cat_id."` ORDER BY `name` ASC";
$link_result = mysql_query($link_query);
$link_num = mysql_numrows($link_result);
$i3 = 0;
while($i3 < $link_num) {
$link_name = mysql_result($link_result,$i3,"name");
$link_url = mysql_result($link_result,$i3,"url");
echo("<a href=\"".$link_url."\" target=\"_blank\">".$link_name."</a>\n");
++$i3;
}
echo("<hr>\n");
++$i2;
}
?>
I get this error:
[FONT=courier new]Warning: Supplied argument is not a valid MySQL result resource in /users/iwebland.com/tafman/perch/pages/links.inc.php on line 27[/FONT]
I do not understand why. I may have gone wrong, I am quite inexperienced. I would appreciate someones help on this, as it is frustrating me!!!
Also feel free to comment on my site so far... PERCh