Kieran-R Posted December 3, 2010 Share Posted December 3, 2010 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) Quote Link to comment Share on other sites More sharing options...
Dayo Posted December 3, 2010 Share Posted December 3, 2010 should carSAVING1 be carSAVING? also try echo'ing your cost1 to see if that is 0 if so there could be your problem Quote Link to comment Share on other sites More sharing options...
Danny696 Posted December 3, 2010 Share Posted December 3, 2010 <a href='cardealership' /> Unless your using .htaccess, shouldnt that have a .php on the end? Quote Link to comment Share on other sites More sharing options...
Kieran-R Posted December 4, 2010 Author Share Posted December 4, 2010 Cost1 is being echoed as 0 too. And yes. carSAVING1 is rights. @danny: Yes I am using .htaccess. Quote Link to comment Share on other sites More sharing options...
Kieran-R Posted December 4, 2010 Author Share Posted December 4, 2010 Also, carSAVING1 is a 0. number, and it is defined as a decimal in the database. Quote Link to comment Share on other sites More sharing options...
Kieran-R Posted December 4, 2010 Author Share Posted December 4, 2010 nvm I fixed it. :) 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.