Dan,
Saturday, August 17, 2002, 7:55:53 PM, you wrote:

DT> I have a table where I have specified several columns which I have specified
DT> that NULL values are not allowed.

DT> I have created a PHP based create / update / delete page where users can
DT> update the table.

DT> I have an INSERT script that takes the user input and generates the
DT> following query statement.

DT> Insert:

DT> INSERT INTO table SET required_field = NULL

DT> I have set the required field to NULL which results in an error because
DT> naturally this is a required field.  If I use an actual value the query runs
DT> fine and the row is added.


DT> Now I have another page that allows the user to update the existing rows.

DT> Update:

DT> UPDATE table SET required_field = NULL WHERE id = '2'

DT> This assumes that the user has cleared a required field and is attempting to
DT> enter NULL data for a required field.  If I execute this directly in mysql
DT> the query fails (0 rows touched).

DT> If I execute this via PHP from the web page the row is updated but it passes
DT> "" instead of NULL so the row is updated.  The query above is echoed right
DT> from the web page and pasted into MySQL.

It's a known feature and it is described in the manual:

     "If you try to store NULL into a column that doesn't take NULL
     values, MySQL Server will store 0 or '' (empty string) in it
     instead. (This behaviour can, however, be changed with the
     -DDONT_USE_DEFAULT_FIELDS compile option.)"





-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Egor Egorov
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to