Jump to content
MakeWebGames

Error/Bug


modernmafia

Recommended Posts

Error When Buying property ?

The error: it cost 25 million To buy a bf but when i have 17 million it allows me to buy it but then my money goes into -(minus) amounts

here the code any help will be greatly appreciated

<?php
error_reporting(0);
session_start();
include_once "includes/db_connect.php";
include_once "includes/functions.php";
logincheck();
$username=$_SESSION['username'];


$fetch= mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));
$bf = mysql_fetch_object(mysql_query("SELECT * FROM bf WHERE location='$fetch->location'"));
$fetch_owner=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$RPS->owner'"));

?>

<?
if ($site->gupdate == "1"){
echo "<link href='style.css' rel='stylesheet' type='text/css'><center><div class='update'>$site->gupdatetext</div></center>

<br>";
}
?>

<link href='style.css' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="/js/select.js"></script>
<style type="text/css">
.select, .selected {
width: 110px;
padding: 10px;
}
</style>
<?php

if($_GET['buyfactory']){

$bf = mysql_fetch_object(mysql_query("SELECT * FROM bf WHERE location='$fetch->location'"));

if($bf->owner == "0"){

if($info->money < 2500000){
echo "<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>You dont have £25,000,000 to purchase this factory!</td></tr></table>";

}else{

mysql_query("UPDATE users SET money=money-25000000 WHERE username='$username'");

mysql_query("UPDATE bf SET owner='$username' WHERE location='$fetch->location'");
mysql_query("UPDATE bf SET jspprice='4500' WHERE location='$fetch->location'");
mysql_query("UPDATE bf SET fmjprice='4500' WHERE location='$fetch->location'");
mysql_query("UPDATE bf SET profit='0' WHERE location='$fetch->location'");

echo"	<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=green>Your now the owner of $fetch->location bullet factory!</td></tr></table>"; 

}}}


?>
<?php

if($_GET['drop']){

$bf = mysql_fetch_object(mysql_query("SELECT * FROM bf WHERE location='$fetch->location' AND owner='$username'"));

if ($bf->owner == $username) {

mysql_query("UPDATE bf SET owner='0' WHERE location='$fetch->location'");
mysql_query("UPDATE bf SET jspprice='4500' WHERE location='$fetch->location'");
mysql_query("UPDATE bf SET fmjprice='4500' WHERE location='$fetch->location'");
mysql_query("UPDATE bf SET profit='0' WHERE location='$fetch->location'");

echo"<br><div class=success>You have dropped the bullet factory in $fetch->location!<br><br>"; 

}}

/////////////////////////////////////////////////////


if(strip_tags($_POST['submit'])){
$type=$_POST['type'];
$amount=strip_tags($_GET['amount']);


if($type == "1"){

$bf = mysql_fetch_object(mysql_query("SELECT * FROM bf WHERE location='$fetch->location'"));

if ($bf->owner == $username) {

echo"	<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>You cant buy from your own factory!</td></tr></table><br>"; }

elseif ($bf->owner != $username) {

$amount=intval(strip_tags($_POST['amount']));

if ($amount == 0 || !$amount || ereg('[^0-9]',$amount)){

print "	<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>You cant buy that amount!</td></tr></table><br>";

}elseif ($amount != 0 || $amount || !ereg('[^0-9]',$amount)){

$costs = $bf->jhpprice * $amount;


if ($costs > $fetch->money){

echo "	<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>You do not have enough money!</td></tr></table><br>";

}elseif ($costs <= $fetch->money){

if ($bf->jhpstock < $amount){

echo "	<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>There isn't enough JHP in stock for you to buy that amount!</td></tr></table><br>";

}elseif ($amount <= $bf->jhpstock){

mysql_query("UPDATE users SET money=money-$costs WHERE username='$username'");

mysql_query("UPDATE users SET JHP=JHP+$amount WHERE username='$username'");

mysql_query("UPDATE bf SET jhpstock=jhpstock-$amount WHERE location='$fetch->location'");

mysql_query("UPDATE bf SET profit=profit+$cost WHERE location='$fetch->location'");

mysql_query("UPDATE users SET money=money+$costs WHERE username='$bf->owner'");

echo"	<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0>

<tr><td class=notice align=center><center><font color=green>You've bought ".makecomma($amount)." JHP for £".makecomma($costs)."!</td></tr></table><br>"; 

}}}}}}

/////////////////////////////////////////////////

if($type == "2"){

$bf = mysql_fetch_object(mysql_query("SELECT * FROM bf WHERE location='$fetch->location'"));

if ($bf->owner == $username) {

echo"	<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>You cant buy from your own factory!</td></tr></table><br>"; }

elseif ($bf->owner != $username) {

$amount=intval(strip_tags($_POST['amount']));

if ($amount == 0 || !$amount || ereg('[^0-9]',$amount)){

print "	<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>You cant buy that amount!</td></tr></table><br>";

}elseif ($amount != 0 || $amount || !ereg('[^0-9]',$amount)){

$costs = $bf->fmjprice * $amount;

if ($costs > $fetch->money){

echo "	<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>You do not have enough money!</td></tr></table><br>";

}elseif ($costs <= $fetch->money){


if ($bf->fmjstock < $amount){

echo "	<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>There isn't enough FMJ in stock for you to buy that amount!</td></tr></table><br>";

}elseif ($amount <= $bf->fmjstock){

mysql_query("UPDATE users SET money=money-$costs WHERE username='$username'");

mysql_query("UPDATE users SET FMJ=FMJ+$amount WHERE username='$username'");

mysql_query("UPDATE bf SET fmjstock=fmjstock-$amount WHERE location='$fetch->location'");

mysql_query("UPDATE bf SET profit=profit+$cost WHERE location='$fetch->location'");

mysql_query("UPDATE users SET money=money+$costs WHERE username='$bf->owner'");

echo"	<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0>

<tr><td class=notice align=center><center><font color=green>You've bought ".makecomma($amount)." FMJ for £".makecomma($costs)."!</td></tr></table><br>"; 

}}}}}

?>

<?php if($bf->owner == "0"){ echo "<link href='style.css' rel='stylesheet' type='text/css'><table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center>This bullet factory has no owner.<br>
The price to buy this factory is £25,000,000.<br>
<a href=?buyfactory=yes>Buy Bullet Factory</a></td></tr></table><br>";exit; } ?>


<br>

<form action='' method='post'>
<input type="hidden" name="type" id="select" value="0"> 

<table width="400" align="center" cellspacing="0" class="table">
<tr class="header"><td colspan="2">Bullet Factory - Owner: <?php if($bf->owner == "0"){ echo "No Owner"; }else{ echo "Owned by <a href='profile.php?viewuser=$bf->owner'>$bf->owner</a>"; } ?></td></tr>

<?php if($bf->producing == "yes"){ ?>
<tr class="subhead"><td colspan="2" align="center">The stock will update in: <?php echo"".maketime($finds_status->bfstocktime).""; ?></td></tr>
<? }else{ ?>
<tr class="subhead"><td colspan="2" align="center">This bullet factory is currently not producing.</td></tr>
<? } ?>

<tr><td height="10"> </td></tr>

<tr><td width='50%' align='center'><div id='1' value='1' class='action select' onclick='SelectOption(this.id, this.className);'><img src='images/items/jhp.png'><br>Jacketed Hollow Point<br>Stock: <?php echo "".number_format($bf->jhpstock).""; ?><br>Cost: <?php echo "£".number_format($bf->jhpprice).""; ?> / per bullet</div></td>

<td width='50%' align='center'><div id='2' value='2' class='action select' onclick='SelectOption(this.id, this.className);'><img src='images/items/fmj.png'><br>Full Metal Jacketed<br>Stock: <?php echo "".number_format($bf->fmjstock).""; ?><br>Cost: <?php echo "£".number_format($bf->fmjprice).""; ?> / per bullet</div></td></tr>

<tr><td height="10"> </td></tr>

<?php if($username == $bf->owner){ ?>

<tr><td class=notice colspan='5' align=center><center><font color=red>You cannot buy from your own Bullet Factory!</td></tr>

<? }else{ ?>

<tr><td align='center' colspan='2'>Bullets: <input type="text" name="amount" class="textbox" id="bullets" autocomplete="off" class="input"></td></tr>
<tr><td align='center' colspan='2'><input type='submit' name='submit' class='button' value='Purchase'></td></tr>
</table>

<? } ?>
</form>	

<table align="center">
<tr>
<td>
<table align="center" cellspacing="0" class="table">
<tr>
<td width="25" align="right"><img src='/images/items/jhp.png' width="25"></td>

<td>You have <?php echo "".number_format($fetch->JHP).""; ?> JHP!</td>
</tr>
</table>
</td>

<td>
<table align="center" cellspacing="0" class="table">
<tr>
<td width="25" align="right"><img src='/images/items/fmj.png' width="25"></td>

<td>You have <?php echo "".number_format($fetch->FMJ).""; ?> FMJ!</td>
</tr>
</table>
</td>

<td>
<table align="center" cellspacing="0" class="table">
<tr>
<td width="25" align="right"><img src='/images/items/gbullet.png' width="25"></td>

<td>You have <?php echo "".number_format($fetch->GoldenBullet).""; ?> Golden Bullets!</td>
</tr>
</table>
</td>

</tr>
</table>


Link to comment
Share on other sites

line40:

if($info->money < 2500000){ 

2500000 => 2.500.000 which is clearly not 25million.

I think you'd like to add a 0 to that? The amount in the query is 25million though.

Also try to intend your code properly, it makes it easier to read for everyone!

Are you using a custom engine, or a game engine listed on here? If so, try to post it in a more specific board next time.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...