Timothy Golden
asked on
help with if/then
strange result from IF/THEN check
in my index.php page i have a check to see if the $id has been passed through the URL
if not then i redirect the user.
When i visit:
http://www.mysite.com/members/?id=
or
http://www.mysite.com/members/index.php
the result of the following is always
if($id = ""){
echo"i am blank";
} else {
echo"i have data";
}
<html><body> "i have data" </body></html>
I've tried $_GET['id'] and $id and both return the same thing
that $id is set and has data
so what's worng with this simple fi/then?
I need to check if the URL contians $id=??? if it's empty or not passed o need to rediredt the user.
in my index.php page i have a check to see if the $id has been passed through the URL
if not then i redirect the user.
When i visit:
http://www.mysite.com/members/?id=
or
http://www.mysite.com/members/index.php
the result of the following is always
if($id = ""){
echo"i am blank";
} else {
echo"i have data";
}
<html><body> "i have data" </body></html>
I've tried $_GET['id'] and $id and both return the same thing
that $id is set and has data
so what's worng with this simple fi/then?
I need to check if the URL contians $id=??? if it's empty or not passed o need to rediredt the user.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In PHP, = is only an assignment operator; you have to use == to compare values, and === to compare values, and make sure they are the same type.
ASKER
yea i tred the == but that didnt work eigher
How are you assigning the value to $id?
You could try something like the following:
if(!(isset($_GET['id'])&&$ _GET['id'] != '')){
echo"i am blank";
} else {
echo"i have data";
}
You could try something like the following:
if(!(isset($_GET['id'])&&$
echo"i am blank";
} else {
echo"i have data";
}
ASKER
well i changed the VAR to a different word and not it's working
if($memberid == ""){
echo"i am blank";
} else {
echo"i have data";
}
when i use $id it does not work but $memeberid does.. strange..
this is the 1st line of code in the page so $id is not being set any where... strange
if($memberid == ""){
echo"i am blank";
} else {
echo"i have data";
}
when i use $id it does not work but $memeberid does.. strange..
this is the 1st line of code in the page so $id is not being set any where... strange