$action = (isset($_REQUEST['action'])&& $_REQUEST['action'] !=NULL)?$_REQUEST['action']:'';
if($action == 'ajax'){
    echo "newtypeid is".$newtypeid;
    //some stuff here

How to get $newtypeid value inside if statement.

Are you sure $_REQUEST['newstype'] actually has a value?

Is the text of your echo being displayed?

How are you sending through 'newstype' (post or get)?

yeah..$_REQUEST['newstype'] value is accesible outside if statement.
I want $newtypeid value inside if statement.
Need suggestions

are you sure you $action has any value like true or false

The problem appears to be in line 3 of your code. It must not be evaluating to 'ajax' and therefore the IF condition is evaluating as FALSE.

Because if you simplify the code, the variable $newtype is working as expected within the IF block.

See this simple example..

$action = "ajax";
if($action == 'ajax'){
    echo "newtypeid is " . $newtypeid;

and results...


Member Avatar

Also - REQUEST - do you really want to be using this? Decide on POST or GET.