function not recognizing variable passing in querystring
Posted: Mon Jun 23, 2003 9:50 pm
Hi,
I am having a helluva time with some pretty simple bits of code and wanted someone to look over it and give me a suggestion. It looks long but it is very straightforward.
I have a couple of functions which pull info from a database, and a couple that display that info. I can get one set to work but not the other. The pair that work are called like so..
and their repsective code...
This works nice. All the links are now passing their respective 'catid'. Okay, now when I click the links it points to this...
and their repsective code...
I always get "No categories currently available", which is not true. There are three. I've done queries in MySqlFront and they all pop up.
The only difference in get_categories and getLinks is that getLinks accepts the catid as a parameter which was passed to it in display_categories. I can see that the catid is being passed when I run the cursor over the links, but getLinks does NOT see it. I have plugged in so many other little functions to test whether catid has a value and it doesn't. It does not make any sense to me whatsoever.
I welcome all suggestions gladly
Thanks
I am having a helluva time with some pretty simple bits of code and wanted someone to look over it and give me a suggestion. It looks long but it is very straightforward.
I have a couple of functions which pull info from a database, and a couple that display that info. I can get one set to work but not the other. The pair that work are called like so..
Code: Select all
$cat_array = get_categories();
display_categories($cat_array);Code: Select all
function get_categories()
{
$query = "select catid, cat_name
from link_cat";
$result = @mysql_query($query);
if(!$result)
return false;
$num_cats = @mysql_num_rows($result);
if($num_cats ==0)
return false;
$result = db_result_to_array($result);
return $result;
}
and
function display_categories($cat_array)
{
if(!is_array($cat_array))
{
echo '<br>No categories currently available<br>';
return;
}
foreach($cat_array as $row)
{
$url = 'subpages/show_cat.php?catid=' .($row['catid']). ' target=content';
//$url = 'includes/show_categories.php?catid=' .($row['catid']). ' target=content';
$title = $row["cat_name"];
do_html_url($url, $title); // This function justs does a little formatting
}
}Code: Select all
$links = getLinks($catid);
displayLinks($links);Code: Select all
function getLinks($catid)
{
$catid = $_GET['catid'];
if(!$catid || $catid=="")
return false;
$query = "select * from links where catid='$catid'";
$result = @mysql_query($query);
if(!$result)
return false;
$num_links = @mysql_num_rows($result);
if($num_links == 0)
return false;
$result = db_result_to_array($result);
return $result;
}
and
function displayLinks($link_array)
{
if(!is_array($link_array))
{
echo '<br>No links currently available in this category<br>';
}
else
{
foreach($link_array as $row)
{
$url = 'show_book.php?linkid=' .($row['linkid']). ' target=content';
$title = $row["catname"];
do_html_url($url, $title);
}
}
}The only difference in get_categories and getLinks is that getLinks accepts the catid as a parameter which was passed to it in display_categories. I can see that the catid is being passed when I run the cursor over the links, but getLinks does NOT see it. I have plugged in so many other little functions to test whether catid has a value and it doesn't. It does not make any sense to me whatsoever.
I welcome all suggestions gladly
Thanks