Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

insert comma

0 views
Skip to first unread message

SurfR

unread,
Apr 14, 2006, 2:50:10 PM4/14/06
to
How do I insert an amount using a comma for the decimals when the database only accepts dots for decimals?

Kind regards,

Robin MEEUWSEN

Michael Fesser

unread,
Apr 14, 2006, 2:51:46 PM4/14/06
to
.oO(SurfR)

>How do I insert an amount using a comma for the decimals when the
>database only accepts dots for decimals?

What database? What scripting language? Why not simply replace the comma
before inserting the value?

Micha

SurfR

unread,
Apr 14, 2006, 4:01:07 PM4/14/06
to
MySQL, PHP. I have a form to input an invoice. MySQL only accepts dots. The is
going to be made using a comma so the centimes are not inserted. 153,76 will
become 153.00

Kind regards,

Robin MEEUWSEN

fwd...@gmail.com

unread,
Apr 15, 2006, 4:02:29 AM4/15/06
to

SurfR wrote:
> MySQL, PHP. I have a form to input an invoice. MySQL only accepts dots. The is
> going to be made using a comma so the centimes are not inserted. 153,76 will
> become 153.00
>

Simply replace the comma before inserting the value. u can use the
str_replace().
<?
$number="153,73";
echo str_replace(",","",$number);
//OUTPUT: 15373
?>

Michael Fesser

unread,
Apr 15, 2006, 4:10:01 AM4/15/06
to
.oO(SurfR)

>MySQL, PHP. I have a form to input an invoice. MySQL only accepts dots. The is
>going to be made using a comma so the centimes are not inserted. 153,76 will
>become 153.00

Then replace the comma before inserting the value.

http://www.php.net/strtr
http://www.php.net/number_format

Micha

gareth

unread,
Apr 15, 2006, 6:39:20 AM4/15/06
to
Use the str_replace function in the code dreamweaver creates to insert the
value eg

wrap $_POST['form_value'] with:

str_replace(",",".",$_POST['form_value'])


--
Gareth
http://www.phploginsuite.co.uk/
PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.


0 new messages