Re: Problems with strings being handled like numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/13/05, Chris <listschris@xxxxxxxxxxxxxxx> wrote:
> 
> Are you sure you're getting the number as you need it from the query?
> 
> PHP won't (though I guess there could be a bug) automatically convert a
> numerical string into it's numerical equivalent.
> 
> If the code you posted produces this problem, then the only possiblities
> I see are that the mssql module is returning a number, or the database
> query is returning that particular string.


(Sorry to Chris for getting this twice, I accidentally didn't reply to the 
list)

First of all, thanks for the absurdly fast reply.

I've been playing with it and it looks like mssql_fetch_row may be the 
problem. Right after this line:

$line = mssql_fetch_row($result);

 ...I inserted this line:

var_dump($line[0]);

...and this is what I got back:

string(20) "3.67124100206018e+17"

The actual contents of that cell should be "367124100206018209". So it looks 
like the contents of the cell have already been mangled before they're even 
assigned to the array variables (which would explain why my previous 
attempts at typecasting at assignment time weren't having any effect...it 
was already a string). Is there some way I can tell mssql_fetch_row() to 
leave the contents alone?

By the way, if I do "SELECT cast(Number as char) from Voucher..." and leave 
the rest of it the same, I do get the whole number...but that seems kinda 
inelegant. Is this expected behaviour for mssql_fetch_row()?

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux