In message <[EMAIL PROTECTED]>, Bob
<[EMAIL PROTECTED]> writes
>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.

Because you have filled the field with 
>ENCODE('$email', 
>'########')
even when $email is ''.   

The default condition would be if you had used the query
>  $sql = "INSERT
>  INTO familyhistory
>  VALUES ('$msg_id', '$family', '$who', '$message')";
and not passed a value into the email field.

I have never used ENCODE and DECODE, but I assume that an empty string
is not acceptable to it - have you tried using this?
SELECT IF(email='', '', DECODE('$email', '########'))

-- 
Pete Clark

Free advertising for your website, business, or organisation at:
http://www.hotcosta.com/resources.php




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/
 



Reply via email to