Jump to content

What could be happening here??


elentz

Recommended Posts

I have some code that updates a table in a Mysql DB. The table fields are decimal 8,2.  If I interrupt the update to the table and echo the variable $formatnet_total I get 2,395.23.  If I let it update the table I get 2 in the field.  What is happening here?

 

$sql = 'SELECT SUM((vtiger_inventoryproductrel.quantity) * (vtiger_inventoryproductrel.listprice))'
        . ' from vtiger_inventoryproductrel'
        . ' where vtiger_inventoryproductrel.id = '.$id.'';

$result = mysql_query($sql,$conn);
$mytotal = mysql_fetch_row($result);
$formatnet_total=number_format($mytotal[0],2,'.',',');

$sql4 ="Update vtiger_invoicecf SET cf_602 = '$mitax', cf_610 = '$formatnet_total' where invoicei = '$id'";
$result = mysql_query($sql4) or die(mysql_error() . "<p>With Query<br>$sql4");

 

 

Thanks for looking!

Link to comment
Share on other sites

Number parsers stop when they find a character that is not part of the data type they are looking for.

 

A coma to separate fields in a number is a human convention not a computer number convention. Only add the coma separator when you display information, not when you store it.

Link to comment
Share on other sites

I checked the manual..

 

http://dev.mysql.com/doc/refman/5.0/en/precision-math-decimal-changes.html

 

It doesn't specifically state that the comma would be the escape.  But it DOES state that it only accepts integers and a "."  It used to accept a "+" or a "-" but those (along with leading zeros) are no longer accepted.

 

It's definitely that comma.  Remove it and then you should be all set.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.