Skip to Content.
Sympa Menu

freetds - problem with fetching NULL values

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Cedric" <cedric AT eolas.fr>
  • To: <freetds AT franklin.oit.unc.edu>
  • Subject: problem with fetching NULL values
  • Date: Tue, 22 May 2001 16:51:39 +0200

Hi,
 
In my database I've got a table like this
 
COL1  | COL2
<null> | item 1
abab   | item 2
<null> | item 3
 
I'am using PHP 4.0.4  and freetds and I want to do a test like this :
"if COL1 is null then echo COL2 else echo COL1"
 
so my code is
----------------------------------
$sql = "COL1, COL2 from myTable";
$rs = mssql_query($sql) or die ("Erreur : $sql<BR>");
$row = mssql_fetch_array($rs);
 
if (is_null($row[COL1]) || ($row[COL1] == "") || !isset($row[COL1]) || ($row[COL1] == NULL)) {
    // case 1
    echo $row[COL2];
} else {
    // case 2
    echo $row[COL1];
}
--------------------------------------
 
unfortunatly it always comes in case 2 and echo nothing.
 
Please help !!
 
thanks
 
PS : I tested a code like this and it doesn't worked too (it always echo XX)
 
---------------------------
$temp = "X" . $row[COL1] . "X";
if ($temp == "XX") {
    echo "something";
} else {
    echo $temp;
}



Archive powered by MHonArc 2.6.24.

Top of Page