Hi, I'll take a wild guess. Maybe $email needs more testing like:
if ( strlen($email) >2) $email might be an empty string but still exist. Also if you have a default value set for the field in mysql, you do not need to set the field to get the default do not assign a value. Also do not assign an empty string like '' for the value or you will get a NULL value. Sincerely, Mike -- Mike Brandonisio * Web Hosting Tech One Illustration * Internet Marketing tel (630) 759-9283 * e-Commerce [EMAIL PROTECTED] * http://www.jikometrix.net JIKOmetrix - Reliable web hosting On Jul 21, 2006, at 5:39 PM, Bob wrote: > I'm having trouble understanding mysql (version 3.23) and I'm using > php4. > > In my home grown message board, if someone leaves a question, it > gives them the option of leaving an email. If someone replies to > their question, it emails them that someone has replied. > > In the query, I use: > if ($email) { > $sql = "INSERT > INTO familyhistory > VALUES ('$msg_id', '$family', '$who', '$message', ENCODE > ('$email', '########'))"; > } > else { > $sql = "INSERT > INTO familyhistory > VALUES ('$msg_id', '$family', '$who', '$message', 'no')"; > } > (which does work) > > I thought I'd be able to use: > `email` varchar(100) NOT NULL default 'no', > but if no email is left, it still leaves it blank. > > And if I try to read 'email' and it's empty, it throws an error, > even if I set 'email' to NULL. > If 'email' doesn't have a value, I can't get it to work, yet all > the books I've got suggest that it should. > > Can anyone throw any light on why I can't read an empty DB value, > or why I can't get default 'no' working? > Thanks, Bob E. > > > ------------------------ Yahoo! Groups Sponsor -------------------- > ~--> > Check out the new improvements in Yahoo! Groups email. > http://us.click.yahoo.com/6pRQfA/fOaOAA/yQLSAA/HKFolB/TM > -------------------------------------------------------------------- > ~-> > > Community email addresses: > Post message: php-list@yahoogroups.com > Subscribe: [EMAIL PROTECTED] > Unsubscribe: [EMAIL PROTECTED] > List owner: [EMAIL PROTECTED] > > Shortcut URL to this page: > http://groups.yahoo.com/group/php-list > Yahoo! Groups Links > > > > > > > > Community email addresses: Post message: php-list@yahoogroups.com Subscribe: [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] List owner: [EMAIL PROTECTED] Shortcut URL to this page: http://groups.yahoo.com/group/php-list Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php-list/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/