Jump to content

assigning a value in if statement is not working


jeff5656

Recommended Posts

  if ($pt_name !== ""){
  $came = "This came from consult list";
  	  }
	  else {
	  $came = "";
	  }

 

Thanks that works but now even if pt_name is blank, I get $came = "This came from consult list";

Why is it not going to the else statement even when pt is blank?

you're not telling it what to do .. for instance, are you asking for the string length to be checked?  or if the string is set or not?  or if it's empty?

 

any one of the following will suffice .. isset() is most common.

 

if (isset ($pt_name))
{
     $came = "This came from consult list";
}
else {
     $came = "not set";
}

 

or...

 

if (strlen($pt_name) > 0)
{
     $came = "This came from consult list";
}
else {
     $came = "no value present";
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.