PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
quadoc
Forum Contributor
Posts: 137 Joined: Fri Jul 01, 2005 5:33 pm
Location: Atlanta, GA
Post
by quadoc » Mon Aug 08, 2005 10:58 am
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"];[/b]
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?>">
Grim...
DevNet Resident
Posts: 1445 Joined: Tue May 18, 2004 5:32 am
Location: London, UK
Post
by Grim... » Mon Aug 08, 2005 11:04 am
Um - what's on line 179 of show.php ?
quadoc
Forum Contributor
Posts: 137 Joined: Fri Jul 01, 2005 5:33 pm
Location: Atlanta, GA
Post
by quadoc » Mon Aug 08, 2005 11:07 am
sorry, line 179 is the first line. For some reasons, there are two posts for this subject, I don't know why. But here is the link to the other post.
viewtopic.php?t=36620
Thanks...
Grim...
DevNet Resident
Posts: 1445 Joined: Tue May 18, 2004 5:32 am
Location: London, UK
Post
by Grim... » Mon Aug 08, 2005 11:15 am
Line 179 is a comment?
Grim...
DevNet Resident
Posts: 1445 Joined: Tue May 18, 2004 5:32 am
Location: London, UK
Post
by Grim... » Mon Aug 08, 2005 11:16 am
Point one:
should really be
nielsene
DevNet Resident
Posts: 1834 Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA
Post
by nielsene » Mon Aug 08, 2005 11:27 am
When pulling in optional fields from GET or POST you should first check if the field is set. If you do this you'll avoid the NOTICE's you're getting.
Code: Select all
$i_order = isset($_GET["order"]) ? $_GET["order"] :
isset($_POST["order"]) ? $_POST["order"] : 1;
Last edited by
nielsene on Mon Aug 08, 2005 1:10 pm, edited 1 time in total.
quadoc
Forum Contributor
Posts: 137 Joined: Fri Jul 01, 2005 5:33 pm
Location: Atlanta, GA
Post
by quadoc » Mon Aug 08, 2005 1:02 pm
Thank you nielsene for the tips...
m3mn0n
PHP Evangelist
Posts: 3548 Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada
Post
by m3mn0n » Mon Aug 08, 2005 1:29 pm
Because it says an error happened on that line, doesn't necessarily mean the problem in your code is on that line.
It just happens to be where the PHP parser ran an error. And it's telling you where the error occured, not where the problem in your source is.
I'd look at 178 and everything above. And not to mention include()'d & require()'d files.
And to give you another tip, undefined index usually means you got registerglobals off and you didn't add something like the following to te top of your code...
Code: Select all
isset ($_POST['var'])
{
$var = trim ($_POST['var']);
}
quadoc
Forum Contributor
Posts: 137 Joined: Fri Jul 01, 2005 5:33 pm
Location: Atlanta, GA
Post
by quadoc » Fri Aug 12, 2005 8:01 am
Thanks for the Tips guys...