Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

php if statement not working

** PHP code, put in HTML for no markup **

How is it not working? It could be multiple things, like below

1. Bad syntax
2. What you're using in the "if" statement might not actually be there.
3. Anything else



Answer 1.

Here's is an example of a bad syntax, using $abc = "abc" as the example. 

if($abc == ""){ /*do something*/ } else { /*do something*/ }

What you really should have is...
if(empty($abc)){ /*do something*/ } else { /*do something*/ }



Answer 2.

If you're using an if statement, you of course got to have what you're checking.
Its no good checking if $abc has the value of "abc", when $abc doesn't even exist.

Rather simple answers above, but I hope it helps. Mostly its bad syntax that causes these problems most of the time.
 
PREVIOUS NEXT
Tagged: #php #statement #working
ADD COMMENT
Topic
Name
6+5 =