Inserting a 'Null' value into my database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Inserting a 'Null' value into my database

Post by Addos »

Hi,
I want to insert a ‘null’ value into my database in certain situations but I’m not having much luck. When I try to use something like

Code: Select all

if(empty($_POST['sheet'])) { $bf = "NULL" ; }
this basically inserts the word NULL into the database and not the italicised one I’d normally see in PHPMyAdmin.

Can anyone point me to what I need to do?
Thanks
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Inserting a 'Null' value into my database

Post by Christopher »

You need to use NULL rather than "NULL" and you need to define the column to allow NULL when you create the table. I think NOT NULL is the default.
(#10850)
Post Reply