error logs reports error in query
Hi Ray
I have several queries similar to the following:
$rsSubMenuContent = new WA_MySQLi_RS("rsSubMenuContent",$conn121_i,0);
$rsSubMenuContent->setQuery("SELECT `page_content`.`pg_id`, `page_content`.`pg_url`, `page_content`.`pg_title`, `page_content`.`pg_sortorder`, `page_content`.`pg_browsertitle`, `category`.`pg_url` AS `UnderPage`, `category`.`pg_id` AS `category`, `category`.`pg_title` AS `categoryname`, REPLACE(`page_mainpics`.`mpic_name`,' ','%20')AS mpic_name, `page_mainpics`.`mpic_alttext`, `page_content`.`pg_description` FROM `page_content` Left Join `page_content` AS `category` ON `page_content`.`pg_under_pgid` = `category`.`pg_id` Left Join `page_mainpics` ON `page_content`.`pg_id` = `page_mainpics`.`mpic_pg_id` WHERE `page_content`.`pg_id` <> 1 AND `page_content`.`pg_active` = 'yes' AND (`category`.`pg_url` = ? OR `category`.`pg_url` = ?) ORDER BY `page_content`.`pg_sortorder` ASC ");
$rsSubMenuContent->bindParam("s", "".$_GET['category'] ."", "-1"); //p1
$rsSubMenuContent->bindParam("s", "".$_GET['pg'] ."", "-1"); //p2
$rsSubMenuContent->execute();
?>
The query works fine - but if I look at the error logs on the server, if there is no 'category' listed, I get:
AH01071: Got error 'PHP message: PHP Notice: Undefined index: category in /home/.../public_html/page.php on line 44'
Line 44 is $rsSubMenuContent->bindParam("s", "".$_GET['category'] ."", "-1"); //p1 above.
Is there a way I can do isset (or something) in the query to get round this error.
Many thanks
Chris