Jump to content

php error


alin19

Recommended Posts

i don't get it, what i have wrong here?

 

if ((isset ($_POST['inreg_contract']))=='Inreg Contract')
{

$query_Sel="SELECT `activ` AS activ FROM `conturi` WHERE  `Id_bo`='$id_bo'";

	if ($r=mysql_query($query_Sel))
		{
		$row = mysql_fetch_array($r);
			$activ=$row['activ'];
		}			

if (isset ($activ)=='Da')
	{
	echo <<<EOF
	<script language="javascript" type="text/javascript">
	<!--


	alert  ('acest client are deja un cont activ, verificati datele');

	-->
	</script>

EOF;
echo $activ;
	}

 

 

and it outputs: Nu and that alert message, but it should'n outpun nothing because $activ is not "Da"

Link to comment
https://forums.phpfreaks.com/topic/98858-php-error/
Share on other sites

You may think it works fine, but it's not doing what you think it is supposed to do.

 

That condition will never evaluate to "true", since the isset() function will return either "true" or "false", which will never be equal to "Inreg Contract".

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/98858-php-error/#findComment-505853
Share on other sites

if you are doing more than a simple IF statement you have to breakdown exactly what you want in the case I answered

if ((isset ($activ))=='Da') //your code
if ((isset ($activ))&&($activ == 'Da')) //my code

in your code the first thing that happens is it checks to see if $active is set, if its true, then nothing else gets checked because there is no conditional statement for another check

in my code it checks to see if $active is set (true) then because of the extra conditional "&&" it also checks to see if its equal to "Da"

 

Link to comment
https://forums.phpfreaks.com/topic/98858-php-error/#findComment-506381
Share on other sites

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.