<?php
$catid = $_GET['catid'];
include("config.inc.php");
if($catid == "")
{
$sql = "SELECT * FROM categories";
$res = mysql_query($sql);
while($row = mysql_fetch_array($res))
{
$formata = "<p><font face=verdana,arial,helvetica size=2><b>";
$category = $row['name'];
$formatb = "</b><br>";
$description = $row['description'];
$formatc = "</font></p>";
print $formata.$category.$formatb.$description.$formatc;
}
} else {
$sql = "SELECT * FROM categories WHERE catid = '$catid'";
$res = mysql_query($sql);
if(mysql_num_rows($res))
{
print "<p align=center><b><font face=verdana,arial,helvetica size=2>Sorry, the category you tried to go to doesn't exist!</font></b></p>";
} else {
}
}
?>
Ok now if I go to url/to/script.php it shows up the correct values from the WHILE statement. If I go to url/to/script.php?catid=1 and I know that catid=1 is one of the values in my db, it still prints the message in the second PRINT statement. Any ideas why this could be and how to fix it?
P.S. I have Register Globals turned off.