Skip to Content.
Sympa Menu

freetds - php sybase truncation problems

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Peter Werner" <peterw AT documenta.com.au>
  • To: "TDS Development Group" <freetds AT franklin.oit.unc.edu>
  • Subject: php sybase truncation problems
  • Date: Fri, 8 Jun 2001 16:42:06 +1000


hi all

we're trying to use php to interact with a sybase database using
freetds. when we run a query through php, the sybase datatype float
is having its last digit truncated. this is odd :)

http://www.viper.net.au/~deanswww/quicksearch.php

this is the best example (source below). the rent per annum is
losing a digit, i dont know if this is a problem with freetds but
thought id ask here anyway.

http://www.viper.net.au/~deanswww/phpinfo.php thats a phpinfo()
script.

any suggestions welcome. im not admin of the webserver or the
database server, but i can probably get any configuration files if
needed.

cheers
-pete

<?php
echo "Rev: 49 <br>";
if (!defined("LOADED")){

include("/usr/home/deanswww/public_html/includes/functions.inc.php")
;
}
$sql[1] = "SELECT * FROM DBA.unitw WHERE rent_pa > 25074 AND unitid
> -1 ";
$sql[2] = "SELECT * FROM DBA.unitw WHERE rent_pa > 25076 AND unitid
> -1 ";
$sql[3] = "SELECT * FROM DBA.unitw WHERE rent_pa > 250740 AND unitid
> -1 ";
$sql[4] = "SELECT * FROM DBA.unitw WHERE rent_pa > 250760 AND unitid
> -1 ";

$db = new DB;
echo
"-------------------------------------------------------------------
-------------------------- <br>";
for ($i = 1 ; $i < 5 ; $i++){
debug($sql[$i]);
$db->query($sql[$i]);

if ($db->num_rows() == 0){
echo "No results returned ... <br>";

}

while ($db->next_record()) {
echo "<P>";
$rent = $db->f("rent_pa");
echo (float)$rent ;
echo "<P>";
echo "Unit id: " . $db->f("unitid") . "<br>";
echo "Street Number: " . $db->f("street_no") . "<br>";
echo "Street Name: " . $db->f("street_name") . "<br>";
echo "Suburb: " . $db->f("suburb") . "<br>" ;
echo "Agency Name: " . $db->f("agency_name") . "<br>";
echo "Status: " . $db->f("status") . "<br>";
echo "Rent PA: " . $db->f("rent_pa") . "<BR>";
echo "Sale Price: " . $db->f("sale_price") . "<br>";
echo "Internal Area: " . $db->f("internal_area") . "<BR>";
echo "Description: " . $db->f("long_description") . "<br>";
echo "Date Added: " . $db->f("date_added") . "<BR>";
echo "Date Modified: " . $db->f("date_modified") . "<br>";
}
echo
"-------------------------------------------------------------------
--------------------------- <br>";
}


?>

----

BUGS
This program does not work very well.
cu(1)






Archive powered by MHonArc 2.6.24.

Top of Page