timmy2 Posted August 2, 2007 Share Posted August 2, 2007 Does anybody have an example code that checks if two variables are the same and if they aren't the same they do something and if they are the same they do something different? Quote Link to comment https://forums.phpfreaks.com/topic/63098-solved-if-varible-varible-echo-else-echo/ Share on other sites More sharing options...
micah1701 Posted August 2, 2007 Share Posted August 2, 2007 what are you asking? it looks like you've basically answered it in the subject line. if($var1 == $var2){ //they match so do something }else{ //they don't match, so do something else } Quote Link to comment https://forums.phpfreaks.com/topic/63098-solved-if-varible-varible-echo-else-echo/#findComment-314322 Share on other sites More sharing options...
timmy2 Posted August 2, 2007 Author Share Posted August 2, 2007 ok thanks I had an idea but I wasn't sure Quote Link to comment https://forums.phpfreaks.com/topic/63098-solved-if-varible-varible-echo-else-echo/#findComment-314325 Share on other sites More sharing options...
timmy2 Posted August 2, 2007 Author Share Posted August 2, 2007 now I'm getting this error Parse error: syntax error, unexpected '{' in mydir on line 18 Quote Link to comment https://forums.phpfreaks.com/topic/63098-solved-if-varible-varible-echo-else-echo/#findComment-314337 Share on other sites More sharing options...
micah1701 Posted August 2, 2007 Share Posted August 2, 2007 'um, look at line 18 of your code. you must have an extra { bracket or something. post your code if you don't solve it yourself. Quote Link to comment https://forums.phpfreaks.com/topic/63098-solved-if-varible-varible-echo-else-echo/#findComment-314342 Share on other sites More sharing options...
premiso Posted August 2, 2007 Share Posted August 2, 2007 Why not post the code instead of having us trying to solve it blindly? Quote Link to comment https://forums.phpfreaks.com/topic/63098-solved-if-varible-varible-echo-else-echo/#findComment-314344 Share on other sites More sharing options...
timmy2 Posted August 2, 2007 Author Share Posted August 2, 2007 line 18 is if($var1 == $var2){ with my own variables Quote Link to comment https://forums.phpfreaks.com/topic/63098-solved-if-varible-varible-echo-else-echo/#findComment-314347 Share on other sites More sharing options...
premiso Posted August 2, 2007 Share Posted August 2, 2007 Why not post the code instead of having us trying to solve it blindly? Seriously, if you want help post most of the code, not one line. There is not necessarily an error at line 18, it could be before it (most likely) in the 17 lines above it or after it (unlikely but possible). Post code, don't be shy we won't steal it. Quote Link to comment https://forums.phpfreaks.com/topic/63098-solved-if-varible-varible-echo-else-echo/#findComment-314349 Share on other sites More sharing options...
timmy2 Posted August 2, 2007 Author Share Posted August 2, 2007 12 <?php 13 error_reporting(E_ALL ^ E_NOTICE); 14 if ($session->logged_in) { 15 $dbh = mysql_connect ("localhost", "user", "password") or die (mysql_error()); 16 mysql_select_db ("db"); 17 //break 18 if($session->userinfo['gething'] == base64_decode($_GET['thing']){ Quote Link to comment https://forums.phpfreaks.com/topic/63098-solved-if-varible-varible-echo-else-echo/#findComment-314353 Share on other sites More sharing options...
premiso Posted August 2, 2007 Share Posted August 2, 2007 if($session->userinfo['gething'] == base64_decode($_GET['thing']) ) { You were missing the closing ) on the if statement. Quote Link to comment https://forums.phpfreaks.com/topic/63098-solved-if-varible-varible-echo-else-echo/#findComment-314354 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.