Skip to Content.
Sympa Menu

freetds - [freetds] freetds, sybase or php error?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Florian Kornhoffer" <f.kornhoffer AT laufwerk.de>
  • To: <freetds AT lists.ibiblio.org>
  • Subject: [freetds] freetds, sybase or php error?
  • Date: Mon, 24 Nov 2008 13:23:40 +0100


Hello,


our provider changed from php4 to php5. Since then we get same strange
return values from some functions, which do a SQL SELECT and returns the
single result value.


Here's some code:

<?php
error_reporting(E_ALL);

include "../connect.syb.php";
syb_connect();

function NeuesDatum( $dDat, $nTage, $cVa, $cLand, $cPlz) {
list($tag, $monat, $jahr) = explode(".", $dDat);
$dDat = sprintf("%04d-%02d-%02d", $jahr, $monat, $tag);

$s = "SELECT DATEFORMAT(AddArbeitstage2Datum ( '$dDat', $nTage,
'KP623', $cVa, '$cLand', '$cPlz' ), 'dd.mm.yyyy')";
echo "SELECT: ".$s."<br>";

$q = sybase_query($s) or die('ungültig: '.$s);
echo "Anzahl Ergebnisse: ".sybase_num_rows($q)."<br>";

$r = sybase_result($q,0,0);
echo "<pre>";
var_dump($r);
echo "</pre>";

return $r;
}

$Va = 1;
$Land = "D";
$Plz = "80333";
$Dat = "24.11.2008";
$x = 1;

echo "Starte NeuesDatum:<br>";
$y = NeuesDatum( $Dat, $x, $Va, $Land, $Plz);
echo "Zurück aus NeuesDatum:<br>";
echo "<pre>";
var_dump($y);
echo "</pre>";
echo "Ende NeuesDatum:<br>";

?>


Output with PHP4 (4.4.7):
Starte NeuesDatum:
SELECT: SELECT DATEFORMAT(AddArbeitstage2Datum ( '2008-11-24', 1,
'KP623', 1, 'D', '80333' ), dd.mm.yyyy')
Anzahl Ergebnisse: 1
string(10) "25.11.2008"
Zurück aus NeuesDatum:
string(10) "25.11.2008"
Ende NeuesDatum:

Output with PHP5 (5.2.6):
Starte NeuesDatum:
SELECT: SELECT DATEFORMAT(AddArbeitstage2Datum ( '2008-11-24', 1,
'KP623', 1, 'D', '80333' ), dd.mm.yyyy')
Anzahl Ergebnisse: 1
string(10) "25.11.2008"
Zurück aus NeuesDatum:
NULL
Ende NeuesDatum:


With php4 the result of the select is as wanted a string and the return
result is the same. With php5 this changed: within the function the
result is the same, but returned value is NULL.

Very interesting too, is the fact, that if I change both var_dump() to
echo $var." (".strlen($var).")<br>";
the return changes again, but it is not NULL but a very long string(!):

PHP4:
within function: 25.11.2008 (10)
returned: 25.11.2008 (10)

PHP5:
within function: 25.11.2008 (10)
returned: QÌh (150890260)


Any ideas??


Florian





Archive powered by MHonArc 2.6.24.

Top of Page