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 11-25-2008, 12:08 AM PHP and Decimals
Novice Talker

Posts: 11
Trades: 0
Alright I made a scoreboard for my site i play on (gaming community) and well in script I have it where if a user scores a ai kill its suppose to give the .5 points.. but for some reason its rounding it to 1 point..

I have the database field type as Decimal but for some reason its not wanting to go into the database as decimal and rounds it up can someone help me please here is what i have

PHP Code:
$aikillpts = ($_POST['aikill'] * .5); 
__________________
~Fear the one they call Smackie for thy who tries and kills thee thy will be died before sunrise Death 10:1~
Smackie is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-25-2008, 03:20 AM Re: PHP and Decimals
Experienced Talker

Posts: 32
Name: Dan
Location: New Zealand
Trades: 0
This code seems to work. Can you explain what $_POST[aikill] would contain? Is this the number of AI's that have been killed?
__________________

Please login or register to view this content. Registration is FREE
/ PHP Web Development and Design Services

Please login or register to view this content. Registration is FREE
Awesome new Facebook app
Rumadon is offline
Reply With Quote
View Public Profile Visit Rumadon's homepage!
 
Old 11-25-2008, 03:29 AM Re: PHP and Decimals
NullPointer's Avatar
Will Code for Food

Posts: 2,784
Name: Matt
Location: Irvine, CA
Trades: 0
Try initializing your variable and casting.

PHP Code:
 $aikillpts 0.00//specify significant digits
 
$aikillpts = (float)($_POST['aikill'] * .5); 
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 11-25-2008 at 08:05 PM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Reply     « Reply to PHP and Decimals
 

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.14426 seconds with 12 queries