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'; } ?> Link to comment https://forums.phpfreaks.com/topic/238292-another-problem/ 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. Link to comment https://forums.phpfreaks.com/topic/238292-another-problem/#findComment-1224531 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 Link to comment https://forums.phpfreaks.com/topic/238292-another-problem/#findComment-1224534 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. Link to comment https://forums.phpfreaks.com/topic/238292-another-problem/#findComment-1224535 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 Link to comment https://forums.phpfreaks.com/topic/238292-another-problem/#findComment-1224537 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. Link to comment https://forums.phpfreaks.com/topic/238292-another-problem/#findComment-1224538 Share on other sites More sharing options...
revraz Posted June 3, 2011 Share Posted June 3, 2011 You want to use OR not AND. Link to comment https://forums.phpfreaks.com/topic/238292-another-problem/#findComment-1224539 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'; } Link to comment https://forums.phpfreaks.com/topic/238292-another-problem/#findComment-1224542 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.