Page 1 of 1

PHP Errors

Posted: Mon Aug 08, 2005 10:59 am
by quadoc
I've the following codes, it keep giving error - Notice: Undefined index: order in c:\Inetpub\wwwroot\schoolProject\admin\show.php on line 179. Can someone tells me why? Thanks...

Code: Select all

/******************* collect sort order (ASC/ DESC)*********************/

	$i_order = $_GET["order"]; / line 179

		if($i_order == "")
		{
			$i_order = $_POST["order"];
		}
		/////////////
		if($i_order == "")
		{
			$i_order = 1;
			$s_sortorder = " DESC ";
		}
		else if($i_order ==  1)
		{
			$i_order = 0;
			$s_sortorder = " DESC ";
		}
		else if($i_order ==  0)
		{
			$i_order = 1;
			$s_sortorder = " ASC ";
		}

		//$i_col = $_GET["col"];


			/************** collect coloumn  no*******************/

		$i_col = $_GET["col"];
		if($i_col == "")
		{
			$i_col = $_POST["col"];
		}
		if($i_col == "")
		{
			$i_col = 3;
		}
		/*********************Switch case statement******************/


		switch($i_col)
		{
			case 0 :
				$s_sort = " order by pir ".$s_sortorder;
				break;
			case 1 :
				$s_sort = " order by email ".$s_sortorder;
				break;
			case 2 :
				$s_sort = " order by categories ".$s_sortorder;
				break;
			case 3 :
				$s_sort = " order by date_request ".$s_sortorder;
				break;	
			case 4 :
				$s_sort = " order by ID ".$s_sortorder;
				break;
			case 5 :
				$s_sort_assgn = 1;
				break;
			case 6 :
				$s_sort = " order by open ".$s_sortorder;
				break;	
		}

  ?>
  <input type=  "hidden" name = "order" value = "<?=$i_order?>">
  <input type=  "hidden" name = "col" value = "<?=$i_col?>">

Posted: Mon Aug 08, 2005 11:19 am
by anjanesh
Are you always able to get output by using <?=$variable?> ?
Is IIS parsing <?=?> ?
What happens when you replace the code with echo ?

Code: Select all

<input type=  "hidden" name = "order" value = "<? echo $i_order; ?>">
<input type=  "hidden" name = "col" value = "<? echo $i_col; ?>">

Posted: Mon Aug 08, 2005 12:06 pm
by skhale
The error is coming from no variable named order being set in $_GET (query string)

You could check for it not being set, that would prevent the error:

Code: Select all

$i_order = (isSet($_GET['order'])) ? $_GET['order'] : null;

Posted: Mon Aug 08, 2005 12:21 pm
by feyd
mutliple threads for the same issue: not cool.

viewtopic.php?t=36619

thread locked.