List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:May 10 2002 6:22pm
Subject:Re: trouble with field NULL
View as plain text  
At 13:11 -0500 5/10/02, Steve Buehler wrote:
>I have found that I can NOT do this:
>$null = "NULL" or even $null = NULL than put that into a statement like this:
>UPDATE games SET game_id = '$null';
>can't do it like this either
>UPDATE games SET game_id = $null;
>I have to do it like this:
>UPDATE games SET game_id = NULL;
>NO QUOTES of any kind.  Somebody else might have a way around this. 
>In that case, I would like to hear it too.  That would let me get 
>around the following:

None of those will work, because you test for NULL using
IS NULL, not = NULL.

>$searchStmt = "UPDATE games SET
>date = '$date',
>time = '$time',";
>if($loc_id == ""){$searchStmt .= "loc_id = NULL,";}else{$searchStmt 
>.= "loc_id = '$loc_id',";}
>if($hteam_pt == ""){$searchStmt .= "hteam_pt = 
>NULL,";}else{$searchStmt .= "hteam_pt = '$hteam_pt',";}
>if($vteam_pt == ""){$searchStmt .= "vteam_pt = 
>NULL,";}else{$searchStmt .= "vteam_pt = '$vteam_pt',";}
>if($sea_id == ""){$searchStmt .= "sea_id = NULL,";}else{$searchStmt 
>.= "sea_id = '$sea_id',";}
>if($hteam == ""){$searchStmt .= "hteam = NULL,";}else{$searchStmt .= 
>"hteam = '$hteam',";}
>if($vteam == ""){$searchStmt .= "vteam = NULL,";}else{$searchStmt .= 
>"vteam = '$vteam',";}
>if($hteam_forfeit == ""){$searchStmt .= "hteam_forfeit = 
>NULL,";}else{$searchStmt .= "hteam_forfeit = '1',";}
>if($vteam_forfeit == ""){$searchStmt .= "vteam_forfeit = 
>NULL,";}else{$searchStmt .= "vteam_forfeit = '1',";}
>if($official_1 == ""){$searchStmt .= "official_1 = 
>NULL,";}else{$searchStmt .= "official_1 = '$official_1',";}
>if($official_2 == ""){$searchStmt .= "official_2 = 
>NULL,";}else{$searchStmt .= "official_2 = '$official_2',";}
>if($official_3 == ""){$searchStmt .= "official_3 = 
>NULL,";}else{$searchStmt .= "official_3 = '$official_3',";}
>if($official_4 == ""){$searchStmt .= "official_4 = 
>NULL,";}else{$searchStmt .= "official_4 = '$official_4',";}
>if($official_5 == ""){$searchStmt .= "official_5 = NULL 
>";}else{$searchStmt .= "official_5 = '$official_5' ";}
>$searchStmt .= "where game_id = '$game_id'" ;
>
>The previous is in a PHP script calling a MySQL DB.
>
>Steve
>
>
>At 12:22 PM 5/10/2002, raphael k wrote:
>>I created a table with a field define as NULL, however when I insert
>>values NULL , Mysql puts 0 instead of nothing ,
>>
>>I don't understand why I have this trouble ,

Thread
trouble with field NULLraphael k10 May
  • Re: trouble with field NULLJoseph Bueno10 May
  • Re: trouble with field NULLSteve Buehler10 May
    • Re: trouble with field NULLPaul DuBois10 May
      • Re: trouble with field NULLSteve Buehler10 May
        • Re: trouble with field NULLPaul DuBois10 May
  • Re: trouble with field NULLNeil Zanella13 May