RE: Strange PHP + MySQL add / update issue with NULL values

From: Date: Sat, 17 Aug 2002 18:00:00 +0000
Subject: RE: Strange PHP + MySQL add / update issue with NULL values
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-113085@lists.php.net to get a copy of this message
Try this instead: INSERT INTO table SET required_field ="" > -----Original Message----- > From: Dan Tappin [mailto:dan@wavefront.ca] > Sent: Saturday, August 17, 2002 12:56 PM > To: mysql@lists.mysql.com; php-general@lists.php.net > 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 <mysql-thread117450@lists.mysql.com> > To unsubscribe, e-mail > <mysql-unsubscribe-aronpilhofer=yahoo.com@lists.mysql.com> > Trouble unsubscribing? Try: > http://lists.mysql.com/php/unsubscribe.php >

« previous php.general (#113085) next »