Driiper Posted January 19, 2008 Share Posted January 19, 2008 Hello everyone! im creating a function for my game that will make players able to buy Territories but im stuck again what i cant remember how i can make a territory buyable only if you have enough money. at this moment you can buy whatever you want the your money will go down to -100000. how can i make a function that says "IF $geld - 100000 < 0 get error message" do anyone know how to do that? <? $dbres = mysql_query("SELECT * FROM `[land]` WHERE `id`='{$_GET['id']}'"); if($profile = mysql_fetch_object($dbres)) { $id = $profile->id; $owning = ($profile->owner == "none") ? "This land is not captured yet!<br> Buy it for $100.000 <form method=\"post\"><input type=submit name=buy value=Buy!></form>" : "Owner: <b><a href=viewprofile.php?viewprofile={$profile->owner}>{$profile->owner}</a></b>."; if($profile->owner =="{$cookieusername}"){ echo "<a href='est.php?type=1'>Start an crew on this land!</a><BR>"; } if(isset($_POST['buy'])) { $data->url = preg_replace('/\</','<',$_POST['website']); $data->muziek = preg_replace('/\</','<',$_POST['muziek']); $data->info = preg_replace('/\</','<',substr($_POST['info'],0,500)); mysql_query("UPDATE `[land]` SET `owner`='{$cookieusername}' WHERE `id`='{$id}'"); mysql_query("UPDATE `users` SET `geld`=`geld`-'100000' WHERE `username`='$cookieusername'"); print " <tr><td class=\"mainTxt\">This land is yours!</td></tr>\n"; } print <<<ENDHTML <br> <br> <center> <table border=1 cellspacing=0 cellpadding=2 width=30% bordercolor=black class=sub2> <tr> <td align=center background=topic.gif>Owner of this land</td> </tr><tr><tr><td class="mainTxt" align="center">{$owning}</td></tr> </table> </center> </form> <br><br><br><br> <br /><br /> ENDHTML; } ?> Link to comment https://forums.phpfreaks.com/topic/86793-solved-need-help-to-create-a-checking-function/ Share on other sites More sharing options...
$username Posted January 19, 2008 Share Posted January 19, 2008 To get started it looks like you need to read up on your PHP if statements. Here is a great place to start http://us.php.net/manual/en/control-structures.if.php this should get you in the right direction <?php if ($a > $b) { echo "a is bigger than b"; $b = $a; } ?> Link to comment https://forums.phpfreaks.com/topic/86793-solved-need-help-to-create-a-checking-function/#findComment-443614 Share on other sites More sharing options...
Driiper Posted January 19, 2008 Author Share Posted January 19, 2008 any way you can help me? Link to comment https://forums.phpfreaks.com/topic/86793-solved-need-help-to-create-a-checking-function/#findComment-443627 Share on other sites More sharing options...
Driiper Posted January 19, 2008 Author Share Posted January 19, 2008 anyone? Link to comment https://forums.phpfreaks.com/topic/86793-solved-need-help-to-create-a-checking-function/#findComment-443832 Share on other sites More sharing options...
trq Posted January 19, 2008 Share Posted January 19, 2008 What is the problem? Link to comment https://forums.phpfreaks.com/topic/86793-solved-need-help-to-create-a-checking-function/#findComment-443841 Share on other sites More sharing options...
Driiper Posted January 19, 2008 Author Share Posted January 19, 2008 This function lets players buy Territorys in the game, but i need to make something that prevent peoples from buying if they dont have enough money, when they try to buy they should get a message saying, "You dont have enough money" i tryed but it didnt work Link to comment https://forums.phpfreaks.com/topic/86793-solved-need-help-to-create-a-checking-function/#findComment-443849 Share on other sites More sharing options...
Driiper Posted January 19, 2008 Author Share Posted January 19, 2008 IF ($geld - 100000 <0) { $message "You dont have enough money"; } else { (This is where my code should go } This didnt work. what am i doing wrong? sorry but im a newb Link to comment https://forums.phpfreaks.com/topic/86793-solved-need-help-to-create-a-checking-function/#findComment-443853 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.