PDA

View Full Version : datatypes in php to mysql



mol
July 26th, 2001, 02:43 PM
Got a double value and this is being inserted into a mysql table field which is of the type decimal (6,4).

Now, when I try to insert this value and it is over 1000.0000 it inserts into the db as 999.9999

For some reason, it will not allow a vlue over that number. I have no idea why. I have verified the datatypes at the time of inserting and everything is correct. Well, everything...SEEMS...to be correct.

Anyone have a clue?

Myst
July 26th, 2001, 03:24 PM
Originally posted by mol
Got a double value and this is being inserted into a mysql table field which is of the type decimal (6,4).

Now, when I try to insert this value and it is over 1000.0000 it inserts into the db as 999.9999

For some reason, it will not allow a vlue over that number. I have no idea why. I have verified the datatypes at the time of inserting and everything is correct. Well, everything...SEEMS...to be correct.

Anyone have a clue?

I was under the impression 6 was the length of the whole decimal and 4 the number of numbers after the decimal - meaning (6,4) would give a range of -99.9999 and 99.9999...

Why are you going from Double to Decimal anyway? Just curious since their range is the same and doubles take less space..

mol
July 26th, 2001, 06:17 PM
Originally posted by WillowRaven


I was under the impression 6 was the length of the whole decimal and 4 the number of numbers after the decimal - meaning (6,4) would give a range of -99.9999 and 99.9999...

Why are you going from Double to Decimal anyway? Just curious since their range is the same and doubles take less space..

Actually, it was just a mistake I made. Im so use to embedded programming that it screws me up sometimes.

Anyway, in mysql I changed that field to a double and everything is fine now. :rolleyes:

I still cant believe I did that...

Myst
July 26th, 2001, 07:11 PM
My "duh" moments usually come when I miscapitalize a function and it ends up throwing 100 various unrelated errors. Forte (by Sun, what we use for JSP) has a TERRIBLE habit of doing this. When you write a JSP it's compiled into a servlet and the servlet is compiled, so half the time you muck up the JSP it still compiles properly into a servlet without errors but then throws an error when you run the servlet. You can't edit the servlet either and it gives no indication of what you did wrong in the JSP...

which is why I much prefer PHP. :)

reanna
July 27th, 2001, 02:51 AM
Originally posted by mol
Got a double value and this is being inserted into a mysql table field which is of the type decimal (6,4).

Now, when I try to insert this value and it is over 1000.0000 it inserts into the db as 999.9999

For some reason, it will not allow a vlue over that number. I have no idea why. I have verified the datatypes at the time of inserting and everything is correct. Well, everything...SEEMS...to be correct.

Anyone have a clue?

(an ever so gentle jab at you wonderful computer wizards:):))


???????????????????
Yah.......okay.......*scratches head totally confused but faking that I understand completely what you are talking about.......:D:D:D:D:D:D

Sorry, I just couldn't resist. :D:D:D:D:D:D:D
However, I am interested. Would you mind if I asked you for a brief description of what you mean? I am totally lost when it comes to most computer lingo.

Myst
July 27th, 2001, 03:28 AM
which part do you need clarification on?

reanna
July 27th, 2001, 03:32 AM
8O 8O 8O ....................................
All of it8O 8O 8O

I totally suck when it comes to understanding this stuff.

Mostly, I don't understand what Mol was doing that created a problem. (hope that sums up what I am confused about.)What is an mysql table ?

TIA

Myst
July 27th, 2001, 07:31 AM
oh boy

I would suggest nevermind'ing would be the easiest thing to do

basically to answer your question I'd have to consolidate two years of college education into a post

uhhhh

(Willow says after getting about 30 mins of sleep this morning)

mol
July 27th, 2001, 09:51 AM
Originally posted by reanna
8O 8O 8O ....................................
All of it8O 8O 8O

I totally suck when it comes to understanding this stuff.

Mostly, I don't understand what Mol was doing that created a problem. (hope that sums up what I am confused about.)What is an mysql table ?

TIA

LOL.

Hey...

http://www.mysql.com

They have all the info there.... ;)

mol
July 27th, 2001, 09:54 AM
Originally posted by WillowRaven


I was under the impression 6 was the length of the whole decimal and 4 the number of numbers after the decimal - meaning (6,4) would give a range of -99.9999 and 99.9999...

Why are you going from Double to Decimal anyway? Just curious since their range is the same and doubles take less space..

Hmm...and about the 6 being the range of the decimal. I dont know if that is correct or not. The value would go all the way up to 999.9999 (which is 7 in length.)

I will read up on the decimal type and tell you what I find out....

Oh, and I didnt create this database...I am just writing the interface to it. Its horrid. Wrong datatypes all over the place. Wasted memory. That little fiasco about the decimal/double made me look into it a little deeper...

Myst
July 27th, 2001, 12:40 PM
Originally posted by mol
Hmm...and about the 6 being the range of the decimal. I dont know if that is correct or not. The value would go all the way up to 999.9999 (which is 7 in length.)


That is what confounded me. For example, it doesn't make sense with what I've read in that 6 usually means the range and you've got 7 there and that's got me lost. Then I thought perhaps it had something to do with the fact that in MySQL 3.22 your sign and decimal count as part of the range, but then the range you could use would have gotten even lower, not higher..

Well to say the least I was lost. Then I wondered why the heck you were doing that anyway; hit on the processor with no benefit to your precision or range as far as I can tell..

But now I understand - you didn't make the db... isn't it fun to muck about with other people's messes? blah

Myst
July 27th, 2001, 12:50 PM
Originally posted by mol


LOL.

Hey...

http://www.mysql.com

They have all the info there.... ;)

Do they have all the database theory too? I think we spent 2 semesters on theory and database design and 1 semester in the actual SQL code. And that doesn't even factor the fact that it's MySQL so it has it's own little quirks...

Ok Reanna, but I have to tell you if you don't know what a table is you've got a LOOOONG way to go on understanding this business :) MySQL is a program that people can use to make databases. I think the technical term for a table is a self describing group of related records...

Imagine you're in an office. Imagine you had a file cabinet of file folders about staff members here at MysticWicks. Each file folder has information for one staff member. Each file folder has information in it like the staff member's name, age, email address, website, etc. In this case the cabinet would be a table. Each file folder would be a row - a row describes one unique person or object and a whole bunch of rows together make up a table.

Try drawing it out on paper, it might make more sense that way.

That's the gist of it anyway :)

mol
July 27th, 2001, 03:10 PM
She asked what a mysql was...

Not what SQL is...

;)

Thats why I gave the web address...

For theory I could recommmend a few books, a few sites, but for a good primer and reference the mysql manual isnt too bad. Of course, it also depends on how you are accessing the db too. There are combo books that give you a good crash course in db's. Like PHP4 Development Guide. This book has a great slant towards mysql and is good for getting started....

Myst
July 27th, 2001, 08:14 PM
Originally posted by reanna
What is an mysql table ?


Actually she asked what a mysql table is

:bigredgri

Database and general SQL theory is an entirely different beast

ladyrowan
July 27th, 2001, 08:18 PM
Originally posted by reanna


(an ever so gentle jab at you wonderful computer wizards:):))
???????????????????
Yah.......okay.......*scratches head totally confused but faking that I understand completely what you are talking about.......:D:D:D:D:D:D
Sorry, I just couldn't resist. :D:D:D:D:D:D:D
.............. I am totally lost when it comes to most computer lingo.

I'm totally with you there! I read the original message and thought, "this is it, i've gone senile. Can't understand a single word of what i'm reading!!
Couldn't even manage an answer to it! :confused:

BB

mol
July 27th, 2001, 11:05 PM
Originally posted by WillowRaven


Actually she asked what a mysql table is

:bigredgri

Database and general SQL theory is an entirely different beast

I stand corrected.

reanna
July 30th, 2001, 04:59 AM
Thanks! I will check out the site mol.


I'm off to see the wizards........ lalalalalalalalalalalalala:D:D:D:D