Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 03-25-2005, 01:34 PM Calculation Error
Hawkallica's Avatar
Novice Talker

Posts: 7
Trades: 0
I am new to php, and I'm trying to make a text based game, but for some reason I have some problems with my calculation on my buildings page. It doesn't give me the right ammount of free land and mountain I can build on. Here is a part of my code.

PHP Code:
$query "SELECT * FROM building WHERE empname='$empname'";
$result mysql_db_query($dbname$query$db);
$myrow mysql_fetch_array($result);

//GET AMMOUNT OF LAND AND MOUNTAIN
$land $myrow["land"];
$mountain $myrow["mountain"];

//LAND
$home $myrow["home"];
$farm $myrow["farm"];
$barracks $myrow["barracks"];
$gtower $myrow["gtower"];

//MOUNTAIN
$goldmine $myrow["gold"];
$ironmine $myrow["iron"];
$lumber $myrow["wood"];
$stonemine $myrow["stone"];

//Find out how much free land
$builtland = ($home $farm $barracks $gtower);
$freeland = ($land $builtland); // = Free land

//Find out how much free mountain
$builtmountain = ($goldmine $ironmine $lumber $stonemine);
$freemountain = ($mountain $builtmountain); // = Free mountain 
I think there is something on these lines
$freeland = ($land - $builtland); // = Free land
AND
$freemountain = ($mountain - $builtmountain); // = Free mountain

cause $mountain and $land is right, and $builtmountain and $builtland is right aswell.

sign up if you want to, I have just 3 pages complete, http://www.HAVOKband.com/GAME/
Hawkallica is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-25-2005, 02:50 PM
Rufo's Avatar
Extreme Talker

Posts: 173
Trades: 0
I can't see anything wrong with those two lines, unless they are strings (though typecasting should have taken care of this).

My only suggestion is that the values are not being selected from the database properly. Try var_dump($myrow); to check what's going on.

Rufo.
__________________

Please login or register to view this content. Registration is FREE
Rufo is offline
Reply With Quote
View Public Profile Visit Rufo's homepage!
 
Reply     « Reply to Calculation Error
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.65129 seconds with 12 queries