469,579 Members | 1,157 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,579 developers. It's quick & easy.

Negative double not stored correctly

Hi All,

I've defined a table (m) with an double field (bedrag) in it and when
I execute the next statement:

INSERT INTO m (bedrag) VALUES('-7000,00');

the value get stored correctly.

I've written a PHP-script which does the following:

$SQL="INSERT INTO m (getal) VALUES('$bedrag')";
$res=mysql_query($SQL);
echo "SQL = ".$SQL."<br>";

When I look at the display from the echo statement it looks like:

SQL = INSERT INTO m (getal) VALUES('-7.000,00')

So that looks OK. But when I do a SELECT * FROM m; in MySQL the stored
value is -7,00 instead of -7000,00. I've defined the bedrag field as
DOUBLE(10,2) so that should not be a problem.
I'm using PHP 4.3.2 and MySQL 4.0.20a.

Can anyone tell me what I'm doing wrong here?

Richard.
Jul 20 '05 #1
2 4503
"Richard van Denzel" wrote:
Hi All,

Iíve defined a table (m) with an double field (bedrag) in it and
when
I execute the next statement:

INSERT INTO m (bedrag) VALUES(í-7000,00í);

the value get stored correctly.

Iíve written a PHP-script which does the following:

$SQL="INSERT INTO m (getal) VALUES(í$bedragí)";
$res=mysql_query($SQL);
echo "SQL = ".$SQL."<br>";

When I look at the display from the echo statement it looks like:

SQL = INSERT INTO m (getal) VALUES(í-7.000,00í)

So that looks OK. But when I do a SELECT * FROM m; in MySQL the stored value is -7,00 instead of -7000,00. Iíve defined the bedrag
field as
DOUBLE(10,2) so that should not be a problem.
Iím using PHP 4.3.2 and MySQL 4.0.20a.

Can anyone tell me what Iím doing wrong here?

Richard.


Whatís "," in 7.000,00. Can you try removing the "," and see
what happens?

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/mySQL-Negati...ict136793.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=457416
Jul 20 '05 #2
Richard van Denzel wrote:
I've defined a table (m) with an double field (bedrag) in it and when
I execute the next statement:

INSERT INTO m (bedrag) VALUES('-7000,00');


As far as I can tell from the documentation, MySQL does not support the
German-style numeric format. You must use "." as the decimal point, and
no thousands separator is supported.

Perhaps one could write a UDF to parse strings in the German numeric
format, and convert them to decimal values before inserting them.
I don't know how to do this, but I imagine it would be possible.

Regards,
Bill K.
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Danny Winslow | last post: by
2 posts views Thread by Richard van Denzel | last post: by
4 posts views Thread by Charles A. Lackman | last post: by
16 posts views Thread by JKop | last post: by
5 posts views Thread by Subrahmanyam Arya | last post: by
44 posts views Thread by Daniel | last post: by
11 posts views Thread by Ole Nielsby | last post: by
8 posts views Thread by SK | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.