Page 1 of 1

[SOLVED] Syntax problem, can't find it

Posted: Tue Jul 06, 2004 10:26 am
by Linkjames
This code checks variables and assigns something to $where based on whether the variables are set.

It should check all the variables, and if they are all empty, then it should leave $where empty, else it should assign it to "WHERE" (SQL select statment is based on this)

Code: Select all

echo $where, $testset, $testsetand, $suiteset, $suitesetand, $groupset, $groupsetand, $productset, $productsetand, $statusset, $statussetand, $ownerset;
echo "<br>";
if ((!isset($testset)) && (!isset($testsetand)) && (!isset($suiteset)) && (!isset($suitesetand)) && (!isset($groupset)) && (!isset($groupsetand)) && (!isset($productset)) && (!isset($productsetand)) && (!isset($statusset)) && (!isset($statussetand))  && (!isset($ownerset)))
{
	$where = "WHERE";
	echo "Set Where";
	echo "<br>";
}
else
{
	$where = "";
	echo "no where";
	echo "<br>";
	
}
The above is leaving $where empty regardless of whether the other variables are assigned or not.

Help, this should work as far as I can see.

Cheers all
LinkJames

*Edit* Meant to say, where I have echoed the variables out, I get a blank line or the variables, so I know they are getting assigned, or left empty as they should be

Posted: Tue Jul 06, 2004 10:46 am
by markl999
and if they are all empty
Just wondering why you're using isset() then and not empty() ? :o
isset() and empty() have different bahaviours, might be worth try empty instead. *shrug*

Posted: Tue Jul 06, 2004 10:47 am
by launchcode
isset() doesn't check to see if a variable is empty - it checks to see if it exists or not. You probably want to use empty().

Posted: Tue Jul 06, 2004 11:06 am
by Linkjames
I was using isset because I did not know that empty() existed, which, as it happens, works perfectly. Thanks a million guys.