JayJabber Posted June 3, 2011 Share Posted June 3, 2011 I dont seem to get this to work. If gold in the database (on a persons data) is 0 or its just empty i want it to show the message below but if its 1 or more i want it to show a file with content in ( The content shows on the page there on) <?php if($gold != 0) { echo "<center><p>You DO not have Gold webclient, Purchase at the Upgrades shop!</p></center>"; } else { echo include 'gold.php'; } ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted June 3, 2011 Share Posted June 3, 2011 So what is the actual problem? Code looks fine. Quote Link to comment Share on other sites More sharing options...
JayJabber Posted June 3, 2011 Author Share Posted June 3, 2011 So what is the actual problem? Code looks fine. I dont know. I it wont show anything like now i've changed it <?php if($gold != 0) { echo "<center><p>You DO not have Gold webclient, Purchase at the Upgrades shop!</p></center>"; } else if($gold != 1) { echo "work?"; } ?> and it still dont work. It wont show the You do not have message if gold is on 0 Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 3, 2011 Share Posted June 3, 2011 replace the if statement with this and try again: if($gold != '0' && $gold != '') // to account for the fact that it may be empty, and also the fact that the number may be a string and not an integer. hope this helps. Quote Link to comment Share on other sites More sharing options...
JayJabber Posted June 3, 2011 Author Share Posted June 3, 2011 replace the if statement with this and try again: if($gold != '0' && $gold != '') // to account for the fact that it may be empty, and also the fact that the number may be a string and not an integer. hope this helps. it helps but now it shows the include file part for 0 and well any number really Quote Link to comment Share on other sites More sharing options...
revraz Posted June 3, 2011 Share Posted June 3, 2011 How are you populating the $gold variable? Post all the code. Quote Link to comment Share on other sites More sharing options...
revraz Posted June 3, 2011 Share Posted June 3, 2011 You want to use OR not AND. Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 3, 2011 Share Posted June 3, 2011 it's actually the other way round: if($gold != '0' && $gold != ''){ // load the file because gold exists }else{ echo 'you dont have any gold'; } 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.