freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: Denis Sokolov <despot AT delfi.lv>
- To: "TDS Development Group" <freetds AT franklin.metalab.unc.edu>
- Subject: money value reading error in php
- Date: Thu, 14 Mar 2002 16:17:51 +0200
Hello all,
PHP Version 4.1.2/FreeTDS latest snapshot/TDS4.2/MS SQL7.0
php compiled --with-sybase=/usr/local/freetds
====================================
$sql_host="192.168.1.2";
$sql_login="loginname";
$sql_pass="passwordstring";
$sql_database="tempdb";
$handle=sybase_connect($sql_host, $sql_login, $sql_pass);
if( !$handle ) die( "Unable to connect to ".$sql_host );
echo "Connect succeed!<BR>";
if( !sybase_select_db( $sql_database, $handle ) ) die( "Unable to select
database ".$sql_database );
echo "USE succeed!<BR>";
for( $tst_value = -1599.95 ; $tst_value >= -1600.05 ; $tst_value -= 0.01 )
{
$qry="SELECT CONVERT(MONEY,".$tst_value.") AS rslt";
$sql_id = sybase_query($qry, $handle);
if( !$sql_id ) die ("Unable to run query [".$qry."]");
$row = @sybase_fetch_array($sql_id);
if( !is_array($row) ) die("No row.");
$dblTst = doubleval($tst_value);
$dblRslt = doubleval($row['rslt']);
echo "Passed: ".$tst_value." Returned value = [".$row['rslt']."]";
if( $dblTst != $dblRslt ) echo " ----- ERROR";
echo "<BR>";
}
exit;
====================================
Result:
====================================
Connect succeed!
USE succeed!
Passed: -1599.95 Returned value = [-1599.9500]
Passed: -1599.96 Returned value = [-1599.9600]
Passed: -1599.97 Returned value = [-1599.9700]
Passed: -1599.98 Returned value = [-1599.9800]
Passed: -1599.99 Returned value = [-1599.9900]
Passed: -1600 Returned value = [-1599.9745] ----- ERROR
Passed: -1600.01 Returned value = [-1600.0100]
Passed: -1600.02 Returned value = [-1600.0200]
Passed: -1600.03 Returned value = [-1600.0300]
Passed: -1600.04 Returned value = [-1600.0400]
Passed: -1600.05 Returned value = [-1600.0500]
====================================
sqsh show this select correctly...
Error in PHP or in FreeTDS?
Thank you.
--
Denis
- money value reading error in php, Denis Sokolov, 03/14/2002
Archive powered by MHonArc 2.6.24.