Problems with strings being handled like numbers

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

 



 I suspect I'm far from the first person to have this problem, but I can't 
seem to find the right search terms to locate the solution. Basically, I'm 
doing a database query and dumping the results into an array. Then, later, 
when I try to display the contents of the array, I run into problems. One of 
the database fields is a very long number, basically an 18-or-so-digit 
serial number. When I tell PHP to print the array variable that corresponds 
to that field, I get what looks like a floating point number in exponent 
notation. I need to display the entire number as it appears in the database. 
Here's the code that does the db lookup and putting the info into the array:

----- cut here
$con = mssql_connect($hostname, $username, $password) or die("Database 
failed to respond.");
mssql_select_db($dbName, $con) or die("Table unavailable.");

$query = "SELECT * FROM Voucher WHERE (Number LIKE '%" . 
$_POST['vouchernum'] . "');";

$result = mssql_query($query, $con);
$result_numrows = mssql_num_rows($result);

$tmpvar = 0;
$vouchers[] = '';
for ($i = 0; $i < $result_numrows; ++$i) {
$line = mssql_fetch_row($result);
$vouchers[$tmpvar][0] = $line[0];
$vouchers[$tmpvar][1] = $line[4];
$vouchers[$tmpvar][2] = $line[5];
$vouchers[$tmpvar][3] = $line[6];
$vouchers[$tmpvar][4] = $line[13];
$vouchers[$tmpvar][5] = $line[14];
$vouchers[$tmpvar][6] = $line[15];
$vouchers[$tmpvar][7] = $line[16];
$tmpvar++;
}
mssql_close($con);

echo("<pre>");
print_r($vouchers);
echo("</pre>");

----- cut here

Basically, $line[0] aka $vouchers[$tmpvar][0] is a really big number and 
it's being treated like a number when I need it to be treated like a string 
and just printed. I tried playing around with typecasting, but I couldn't 
get it to do anything different.
Thanks in advance for any help, and if I need to provide more info feel free 
to let me know.

[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