I have a session variable that shows up in the url:
http://www.panhandleguitar.com/show_cat.php?catid=5
And when I check to see if it registered whith session_is_registered function it returns true. The problem is I cant reference it anywhere or echo it.
This is the code I am using:
Query Functions-
function get_categories()
{
$conn = db_connect();
$query = "select catId, catName from categories";
$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;
}
function get_category_name($catid)
{
$conn = db_connect();
$query = "select catName from categories where catId = $catid";
$result = mysql_query($query);
if(!$result)
return false;
$num_cats = mysql_num_rows($result);
if($num_cats == 0)
return false;
$result = mysql_result($result, 0, "catName");
return $result;
}
function get_inventory($catid)
{
$conn = db_connect();
$query = "select id, brand, model, year, price, img from inventory where catId = $catid";
$result = mysql_query($query);
if(!$result)
return false;
$num_inv = mysql_num_rows($result);
if($num_inv == 0)
return false;
$result = db_result_to_array($result);
return $result;
}
output functions-
function display_categories($cat_array)
{
if(!is_array($cat_array))
{
echo "No categories currently avaialble<br>";
}
echo "<ul>";
foreach($cat_array as $row)
{
$url = "show_cat.php?catid=".($row["catId"]);
$title = $row["catName"];
echo "<li>";
do_html_url($url, $title);
}
echo "</ul>";
}
function display_inventory($inv_array)
{
if(!is_array($inv_array))
{
echo "No items currently available.<br>";
return;
}
echo "<table>";
foreach($inv_array as $row)
{
$id = $row["id"];
$brand = $row["brand"];
$model = $row["model"];
$year = $row["year"];
$price = $row["price"];
$img = $row["img"];
$info = "more_info.php?id=".($row["id"]);
echo "<tr><td><img src = '$img' width = '55' height = '85'></td></tr>";
echo "<tr><td>$year $brand $model</td></tr>";
echo "<tr><td>$$price</td></tr>";
echo "<tr><td>"; do_html_url($info, "complete description"); echo "</td></tr>";
}
echo "</table>";
}
Php pages-
Show_cat.php
<?php
session_start();
include('panhandle_fns.php');
$name = get_category_name($catid);
do_html_header($name);
$test = session_is_registered("catid");
//get item info out of db
$inv_array = get_inventory($catid);
if($test == true)
{
echo "Variable is registered.";
echo "CatId: ";$HTTP_SESSION_VARS['catid'];
}
else
{
echo "Variable is not registered>";
exit;
}
display_inventory($inv_array);
do_html_url("http://www.panhandleguitar.com", "Home");
?>
index.php
<?php
session_start();
session_register("catid");
include('panhandle_fns.php');
do_html_header("Buy, Sell, Trade Used & Vintage Guitars, Amps & Basses");
echo "<h3>Menu</h3>";
//get categories out of database
$cat_array = get_categories();
//display as links to cat pages
display_categories($cat_array);
do_html_footer();
?>
the page index.php works fine, its is the show_cat.php that I am haveing trouble with.