Mudsaf Posted August 6, 2012 Share Posted August 6, 2012 Hello, now im trying to make this code working. $number = rand(0, 5); if ($_GET['code'] == '$c' . $number) {echo "The code was correct.";} else {echo "The code was wrong";} So the code below only pastes it as text so it doesn't really use the variable what comes example $c1. echo '$c' . $number; so i got variables like these. $c1 = 12361 $c2 = 26323 and i wan it go check if get code == $c + number. Link to comment Share on other sites More sharing options...
birbal Posted August 6, 2012 Share Posted August 6, 2012 single quote wont evaluate value. double quote will if($_GET['code']=="{$c}{$number}") Link to comment Share on other sites More sharing options...
kanchatchai Posted August 6, 2012 Share Posted August 6, 2012 Like this or not <?PHP //test filename.php?code=3$number = rand(0, 5); $c='c';if ($_GET['code'] == $$c.$number){echo "The code was correct.";} else {echo "The code was wrong";}//echo '<br/>'.$$c.$number;?> Link to comment Share on other sites More sharing options...
Mudsaf Posted August 6, 2012 Author Share Posted August 6, 2012 Like this or not<?PHP//test filename.php?code=3$number = rand(0, 5);$c='c';if ($_GET['code'] == $$c.$number){echo "The code was correct.";} else {echo "The code was wrong";}//echo '<br/>'.$$c.$number;?> Tried to echo $$c.$number;Pasted following text c3 Link to comment Share on other sites More sharing options...
Mudsaf Posted August 6, 2012 Author Share Posted August 6, 2012 single quote wont evaluate value. double quote will if($_GET['code']=="{$c}{$number}") This pastes only number aswell :/ Link to comment Share on other sites More sharing options...
birbal Posted August 6, 2012 Share Posted August 6, 2012 sorry, i misunderstood the problem.try it ${"c$num"} 1 Link to comment Share on other sites More sharing options...
Mudsaf Posted August 6, 2012 Author Share Posted August 6, 2012 sorry, i misunderstood the problem.try it${"c$num"} Thanks, working Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now