PHP if statement problems

NoCapApps

Member
Messages
45
Reaction score
2
Points
8
I Im trying to make a sign in section in my website and my if statement is always counted as true. the code I have is
$testword = "test";
if($testword = "testing"){
echo "yes";
}

the website always displays yes.
 

spacresx

Community Advocate
Community Support
Messages
2,203
Reaction score
196
Points
63
x10 hosting does not provide script support.
i suggest you try php support sites.
also other forum users might be able to help you.
 

mrburnsx

Community Advocate
Community Support
Messages
577
Reaction score
61
Points
28
I Im trying to make a sign in section in my website and my if statement is always counted as true. the code I have is
$testword = "test";
if($testword = "testing"){
echo "yes";
}

the website always displays yes.
Single = is an assignment operator so that would always return true, when comparing for equality you need at least a double equals ==
 
Last edited:

NoCapApps

Member
Messages
45
Reaction score
2
Points
8
Single = is an assignment operator so that would always return true, when comparing for equality you need at least a double equals ==
thanks! I have never seen double = in php, but I guess I should have known as I have used it frequently in other languages.
 
Top