Jump to content
MakeWebGames

Why Is This Happening?


Kieran-R

Recommended Posts

Hey.

Well I was making a mob for my game and ive done next to all of it. I was just encountering a problem which I will explain bellow.

Well i have made the most part of a car mod for my game. When a user has a car, it reduces there traveling cost. The reduction depends on the car.

 

<?php
require_once(dirname(__file__) .'/globals.php');
$_GET['to'] = (isset($_GET['to']) && !empty($_GET['to'])) ? intval($_GET['to']) : false;
if ($ir['car']==0){
echo "You do not own a car! However, you may buy one from the [url='cardealership']car dealership[/url].";
$h->endpage();
exit();
}
$q=$db->query("SELECT * FROM cities WHERE cityid != {$ir['location']} AND cityminlevel <= {$ir['level']}");
$r=$db->fetch_row($q);
$mycar = $db->query("SELECT * FROM cars WHERE carID={$ir['car']}");
$ic=$db->fetch_row($mycar);



if(!$_GET['to'])
{
print"
<h3>Car Travel</h3>
Where would you like to travel today in your {$ic['carNAME']}?
<font size = 1><font color = black>[b]
Please Note: Because you own a {$ic['carNAME']}, you can
travel {$ic['carSAVING']}% cheaper price!</font></font>[/b]";
$q=$db->query("SELECT * FROM cities WHERE cityid != {$ir['location']} AND cityminlevel <= {$ir['level']}");
print "<table width=75% cellspacing=1 class='table' border='1'><tr style='background:gray'><th>Name</th><th>Min Level</th><th>Price</th><th></th></tr>";
while($r=$db->fetch_row($q))
{
$cost1 = $r['citycost'] * $ic['carSAVING1'];
$cost2 = $r['citycost']-$cost1;
print "<tr><td>{$r['cityname']}</td><td>{$r['cityminlevel']}</td><td>$cost2</td><td>[url='cartravel.php?to={$r[']Go[/url]</td></tr>";
}
print "</table>";

 

As you may see, I am specifying $cost1, and $cost2 which is defining the cost of which it will charge the user. And yes, the coulomb carSAVING1 is defined as a decimal in the DB.

But the problem is, when $cost2 (the final cost value) is echoed out, It is returning 0 when it most defintally shouldnt be.

I relise I may not have explained my problem to well, but if someone could help me out in this situation then it would be great!

(Please not, the code posted here is not the full code. Only a section)

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...