Jump to content

pHp number format


pd_it_guy

Recommended Posts

What am I not seeing here. I have a simple? pHp page that retrieves data from a MS SQL db. The data in question, in the db, is set to numeric (18,0). I typed it in personally. rin: 120primary: 200823443exh_no: 33195When I retireve the data using ADO/ASP it comes out and displays exactly as expected, 120, 200823443, and 33195. No problem.Also, confirmed as numeric (stays to the right) in Excel on an External Data ODBC download. Displays exactly as expected and as input.BUT when I retrieve and display it using pHp in ECHO mode, I get, 120.00, 200,823,443.00, and 33,195.00. I tried converting it to Integer, and all it gave back was the digits before the first comma. Printf and number_format each fixed the decimal problem, but didn't know what to do with commas. What I finally had to do is strip out the commas that pHp chose to add using str_replace and THEN convert it to an Integer. Is this normal for pHp to decide on its own what to do with numbers.Any ideas please. I would hate to have to do this to all numbers.

Link to comment
Share on other sites

I don't think PHP is adding the commas and decimal, I believe that is how it is receiving the data from the database. I might be wrong though.If you're using the MSSQL extension for PHP, check the config settings:http://www.php.net/manual/en/mssql.configuration.phpThose are all of the settings for the MSSQL extension. If you're using the ODBC extension it has these settings:http://www.php.net/manual/en/odbc.configuration.phpIf you want to change any of those settings at runtime, you can use the ini_set function.Also, you spelled PHP with lowercase Ps 5 times, what's up with that?

Link to comment
Share on other sites

Absolutely correct on that one. I took a second look in MSQuery and sure enough it was coming over from the SQL server with all that stuff attached. I changed the data type to varchar(50) and it cleaned it right up. Now we echo exactly what was in the db. You would think if you specified an integer you'd get one but apparently that's not how it works.And is "php" supposed to be lowercase, uppercase or what.Thanks...

Link to comment
Share on other sites

You would think if you specified an integer you'd get one but apparently that's not how it works.
Not when it's up to Microsoft. Things like this make you wonder if they intentionally make their products send different results to ASP vs. other languages. Sort of like when they had MSN serve an Opera-only stylesheet to Opera which had a bunch of negative margins and moved content off the page, then tried to claim that Opera wasn't rendering MSN correctly.
And is "php" supposed to be lowercase, uppercase or what.
I've seen both, I just haven't seen much mixed case.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...