PDA

View Full Version : INT UNSIGNED DEFAULT NULL


Fortune
03-09-2000, 03:21 AM
I have a field called "Price" in mySQL database. It was defined as:
Price INT UNSIGNED DEFAULT NULL,

When a visitor filled my cgi form and left this field blank, there was no problem. When I viewed this field in phpMyAdmin, this field was blank.

However; if later the visitor modified his data and left this field blank again, this field would be automaticly[nbsp][nbsp][nbsp][nbsp]filled with '0'. I also couldn't modified it to be blank by phpMyAdmin.

I want it to be NULL, not 0. Any idea?

Any help is greatly appreciated. Thanks.

Justin
03-09-2000, 11:50 AM
I'm not sure why you would want it to be null... but what you will need to do is pass 'NULL' to the database. Within your code, maybe something like this:

if (!$price) $price = "NULL";

Though for numeric fields it is usually best to define them as 'not null', for much faster indexing, and less confusion on a left join...

Hope this helps.

------------------
Justin Nelson
FutureQuest (http://www.FutureQuest.net/index.php) Support