pocobueno1388 Posted June 24, 2007 Share Posted June 24, 2007 What I am trying to do is create an if statement that is made out of purely variables, but I am having trouble getting it to work properly. Here is my code, I will comment through it to help you understand: <?php //I select the fields I am dealing with from the database. $funInfo = mysql_query("SELECT discipline, height FROM horses WHERE horseID='$horseID'"); $f = mysql_fetch_assoc($funInfo); //Here are the two variables I am working with $stat = trim($split_first[0]); //echos out "discipline" $split_first[1]; //This variable got it's value earlier in the script. It echos out "== 'western' " //Build the IF statment if ($f[$stat].$split_first[1]){ echo 'The statement is true!'; } ?> So I am basically trying to get this line: if ($f[$stat].$split_first[1]){ to be read as an if statement by PHP that should look something like this: if (english == 'western'){ But for some reason it is always returning true....and it shouldn't. Any advice on how to build this if statement with variables would be greatly appreciated. Thanks xD Quote Link to comment Share on other sites More sharing options...
game2002 Posted June 24, 2007 Share Posted June 24, 2007 try strcmp function. if (strcmp(tolower($str1), tolower($str2) == 0) // they are equal. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 24, 2007 Author Share Posted June 24, 2007 Ah, thanks. The strcmp() function is just what I was looking for. Quote Link to comment 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.