List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:June 5 1999 7:09pm
Subject:Re: Not Null
View as plain text  
At 1:03 PM -0500 6/5/1999, Robert Pruitt wrote:
>Hi,
>
>I have a small table --
>
>CREATE TABLE diecast (
>  stock_number varchar(20) binary NOT NULL,
>  item_description tinyblob NOT NULL,
>  sales_price decimal(7,2) DEFAULT '0.00' NOT NULL,
>  class char(1) DEFAULT 'n' NOT NULL,
>  PRIMARY KEY (stock_number));
>
>
>I have created a form, using PHP, a portion of which is --
>$query = "INSERT INTO diecast VALUES ('$stock_number', '$item_description',
>'$sales_price', '$class')";
>
>I have noticed, that should the user simply not enter anything, mysql takes
>it anyway. Only once for stock_number, which is the primary key, indefinitely
>on other fields. I thought NOT NULL would cause an error? I intend to install
>a form validation routine to handle this, still, I'm curious.


If your variables don't have any value, you're specifying an empty
string for that field.  That's different than NULL, so you're not
actually inserting NULL and that's why you're not seeing an error.

--
Paul DuBois, paul@stripped
Northern League Chronicles: http://www.snake.net/nl/
Thread
Dates in MySQLChristopher R. Jones3 Jun
  • Re: Dates in MySQLSasha Pachev3 Jun
  • Re: Dates in MySQL(Paul D. Smith)3 Jun
  • Re: Dates in MySQLVan4 Jun
    • Re: Dates in MySQLBenjamin Pflugmann5 Jun
  • Re: Dates in MySQLJim Faucette5 Jun
  • Not NullRobert Pruitt5 Jun
    • Re: Not NullPaul DuBois5 Jun