On Fri, 28 Mar 2003, Dan Jewett wrote: > I'm having trouble getting NULLs into date/time fields and interval > fields. > > I've gotten this far: > > $trk_length = $_POST['trk_length']; > if (empty($trk_length)) //or if($trk_length == '') > $trk_length = NULL; > > or > > $length_str = $_POST['trk_length']; > if (empty($length_str)) > $trk_length = NULL; > else $trk_length = $length_str; > > The insert: > > $result = pg_query($conn, "INSERT INTO track (field1, field2, > trk_length) VALUES ('$var1', '$var2', '$trk_length')"); > > This results in a "bad external representation ''." error for the > insert. If I use double quotes, ie. $trk_length = "NULL"; and remove > the single quotes from the $trk_length variable in the insert > statement, the insert succeeds. But now, if $trk_length is not empty, > the insert fails with a parse error on the : character in my interval > string. embed the single quotes into $trk_length. if(empty($trk_length)) $tkln = "NULL"; else $tkln = "'$trk_length'"; ... VALUES ('$var1', '$var2', $tkln)"); Vince. -- Fast, inexpensive internet service 56k and beyond! http://www.pop4.net/ http://www.meanstreamradio.com http://www.unknown-artists.com Internet radio: It's not file sharing, it's just radio.