...

View Full Version : undefined index error



eatit007
11-27-2010, 11:07 AM
could u help me with this code...

it gives me
"Notice: Undefined index: action in C:\wamp\www\...\posts.php on line 9"



include($_SERVER['DOCUMENT_ROOT'].'tumblelog/models/post.php');

$action = $_GET['action'];

switch($action) {

case "show":
$post=find_post(2);
echo "This is the show action";
break;
}


Thanks in advance

abduraooft
11-27-2010, 11:40 AM
$action = $_GET['action'];

switch($action) {

case "show":
$post=find_post(2);
echo "This is the show action";
break;
} Change the above to


if(isset($_GET['action'])){
$action = $_GET['action'];

switch($action) {

case "show":
$post=find_post(2);
echo "This is the show action";
break;
}
}

eatit007
11-27-2010, 11:44 AM
Thanks bro..but I solved it .
Used this code...



include($_SERVER['DOCUMENT_ROOT'].'tumblelog/models/post.php');
if (isset($_GET["action"]))
$action = $_GET["action"];
else $action="";
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum