CoffeeAddict Posted February 22, 2013 Share Posted February 22, 2013 Below is the code I'm trying to use, it works perfectly IF the color in the database is listed as "blue_merle". Problem being, it is not, it's listed as "Blue Merle". How can I make this continue to work without having to change the way the color is listed in the database? If I put "Blue Merle" in the php code then it just causes an error because of the space between the words. Help please? I feel like this is probably really simple to fix but it's going right over my head. else if ($dog1->color == blue_merle && $dog2->color == blue_merle) { echo '<p>You cannot breed two merles.</p>'; Quote Link to comment Share on other sites More sharing options...
Barand Posted February 22, 2013 Share Posted February 22, 2013 String values should be in quotes else if ($dog1->color == 'blue_merle' && $dog2->color == 'blue_merle') { echo '<p>You cannot breed two merles.</p>'; Quote Link to comment Share on other sites More sharing options...
CoffeeAddict Posted February 22, 2013 Author Share Posted February 22, 2013 Thanks! I just tried that and it still lets me breed two merles together when it should be throwing the echo message Quote Link to comment Share on other sites More sharing options...
Barand Posted February 22, 2013 Share Posted February 22, 2013 What do $dog1->color and $dog2->color contain? Quote Link to comment Share on other sites More sharing options...
CoffeeAddict Posted February 22, 2013 Author Share Posted February 22, 2013 (edited) They are both listed as Blue Merle. With the space. If I change them to blue_merle with the underscore, it works. But I'd like to avoid having to change it. Edited February 22, 2013 by CoffeeAddict Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 22, 2013 Share Posted February 22, 2013 If the database says "Blue Merle", you need to compare to "Blue Merle", not 'blue_merle'. *smh* Quote Link to comment Share on other sites More sharing options...
CoffeeAddict Posted February 22, 2013 Author Share Posted February 22, 2013 Got it, tried it with the quotes and no space, but forgot to capitalize the words! Works great now. Thank you! 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.