[SOLVED] Syntax problem, can't find it

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Linkjames
Forum Commoner
Posts: 90
Joined: Tue Sep 16, 2003 8:39 am

[SOLVED] Syntax problem, can't find it

Post 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
Last edited by Linkjames on Tue Jul 06, 2004 11:07 am, edited 1 time in total.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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*
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post 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().
Linkjames
Forum Commoner
Posts: 90
Joined: Tue Sep 16, 2003 8:39 am

Post by Linkjames »

I was using isset because I did not know that empty() existed, which, as it happens, works perfectly. Thanks a million guys.
Post Reply