Try this instead:

INSERT INTO table SET required_field =""

> -----Original Message-----
> From: Dan Tappin [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, August 17, 2002 12:56 PM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Strange PHP + MySQL add / update issue with NULL values
>
>
> I have a table where I have specified several columns which I
> have specified
> that NULL values are not allowed.
>
> I have created a PHP based create / update / delete page where users can
> update the table.
>
> I have an INSERT script that takes the user input and generates the
> following query statement.
>
> Insert:
>
> INSERT INTO table SET required_field = NULL
>
> I have set the required field to NULL which results in an error because
> naturally this is a required field.  If I use an actual value the
> query runs
> fine and the row is added.
>
>
> Now I have another page that allows the user to update the existing rows.
>
> Update:
>
> UPDATE table SET required_field = NULL WHERE id = '2'
>
> This assumes that the user has cleared a required field and is
> attempting to
> enter NULL data for a required field.  If I execute this directly in mysql
> the query fails (0 rows touched).
>
> If I execute this via PHP from the web page the row is updated
> but it passes
> "" instead of NULL so the row is updated.  The query above is echoed right
> from the web page and pasted into MySQL.
>
> Any idea?
>
> Thanks,
>
> Dan
>
>
> ---------------------------------------------------------------------
> 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
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to