Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

high numbers in PHP

Status
Not open for further replies.

tcardoso

Programmer
Jan 31, 2005
56
PT
Hi...

I have a function where I have a value of 1200000 and php transform it to 1.2E6 and when I put it on the DB it stays 1 :( in there!

How can I make php to put to normal big number? should I make it strval?

Thanks
 
Some more info:

The field in DB in bigint(40)
if I sum +1 then php no more treats like 1.2E6, but then I remove -1 and it comes back to 1.2E6!

Help :(
 
Integers in php are smaller then the BIGINT in MySQL. So either pass the numbers as strings or format them the right way. PHP automatically converts too big integers to floats, as they can hold higher numbers. There is an extension to do math with arbitrary precision, however.
 
Can you explain how do I do that:

$worked['cost'] is 2000000

Code:
$price = floor($worked['cost'] * 0.60);
$newmoney = $usermoney + $price;
$result = mysql_query("UPDATE `table` SET `money` = '".$newmoney."' WHERE `id`='".$id."'");

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top