The following code goes through the loop perfectly for one category and it's associated links, but then on all subsequent loops produces the errors:
Warning: mysql_db_query(): supplied argument is not a valid MySQL-Link resource in links.php on line 92
and
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in links.php on line 95
I've indicated these lines.
I've been staring at the code for a while now and have got to the stage where it's probably something learingly obvious and amateurish, but just can't see it.
Please can someone tell me why it's not working and if necessary how to fix it.
Cheers
Mark
<?php
/ Retrieve the config file with the database details /
require("../../db_connect.inc");
/ Define data to retrieve from the database /
$define_categories = "SELECT id, category FROM link_categories";
/ Retrieve the information from the database /
$get_categories = mysql_db_query($dbase,$define_categories,$link);
/ Count retrieved data to check if data is present /
$count_categories = mysql_num_rows($get_categories);
if($count_categories >= 1)
{
while($category = mysql_fetch_array($get_categories))
{
print("<p>category[category]</p>");
/ Define data to retrieve from the database /
$define_links = "SELECT name, link, description FROM links WHERE category = '$category[id]' ORDER BY id";
/ Retrieve the information from the database /
##-> row 92 $get_links = mysql_db_query($dbase,$define_links,$link);
/ Count retrieved data to check if data is present /
##-> row 95 $count_links = mysql_num_rows($get_links);
if($count_links >= 1)
{
while($link = mysql_fetch_array($get_links))
{
$link[name] = strip_tags($link[name]);
$link[description] = strip_tags($link[description]);
if($link[name] != "")
{
print("$link[name]<br>");
} //end if statment - name of link exists
if($link[description] != "")
{
print("$link[description]<br>");
} //end if statement - description for link exists
print("<a href=\"$link[link]\" target=\"_blank\">$link[link]</a><br><br>");
} //end while loop - loop through display links in category
} //end if statment - links exist in category so it's OK to display the category
} //end while loop - loop through displaying the categories
} //end if statment - categories present
else
{
print("There are no links currently available at this time.");
} //end else statment - no categories found
?>