I am having a trouble when I save integers to my MYSQL database then when I call them in PHP , It instantly trim every Zero in the ending or the beginning of the integer I Have received from the database ? Is there anyway to work my way around this ? Thanks in advance, Kind Regards, Issa Shamoun. Edit :- I might as well specify that I call the integers into an HTML Text Input not an Echo message Thought this might help
i thought the point of having integer is it behave like a number. if you input 000001.20000000 will be saved 1.2. all integer behave the same way if you really want to keep the zero, save it as string or text. hope that helps
Thanks for sorting this out ! Many Thanks ! So if i want to save phone numbers i have to save it as a string ? and can you explain more about it would a number such as "20" be "2" if i set it as an integer ? Edit :- Ops sorry i figured it out =) thanks again
i think 20, 200, 20000 will be saved that way. but integer have their limitation. i don't remember the exact number, but if you must use long number, use big int instead php only trims 0.20000000 to 0.2
If it's PHP5 then you can force the variable to be a string using it's cast: If it's PHP4, you'd have to use the strval function: Or of course, if you are setting the variable absolutely, just put quotes around it: