Insert Empty String Instead of NULL

Using PHP and MySQL
I do not do a lot of custom inserting. I have a form and am using Dreamweaver CS5 to insert the form variables into a MySql table. Some of the form fields are optional. When I test this form and do not fill out a field, I get a Column 'colName' cannot be null.

I could I guess easily enough mark each of my columns with a default value of NULL but I'm afraid that when the table results are printed it will show NULL for that empty field.

How can I get form variables that do not have a value to show as an empty string in the database?
LVL 16
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Cornelia YoderArtistCommented:
Why don't you try setting one field to NULL and see if it prints "NULL" or nothing.  That's the easy way to check.  You can always change it right back.

I believe (without setting up a test), that a field with null value will show nothing.  

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lukasz ChmielewskiCommented:
or setting any of these optional as value="" will give you a NOT NULL but an empty value.
rbudjAuthor Commented:
I would have just given each input a value="" so it would input empty string but I am using validation so the value is populated.

yodercm, I may have to setup a test form for this. Will take me a bit. My other form is 6 pages long with 100 database rows. You can imagine the nightmare testing can be. I'll report back.

I just figured there was a common function for this.
rbudjAuthor Commented:
Thanks for the answers. Again, I use WebAssist and when form data that is uploaded that is null, it just inserts an empty string in the database. Which is MUCH better than looking at a bunch of NULL's. Just thought there was a function or something to take care of this. I created a test form and the null column field does not disply the word NULL so this is good. I can work with it until I figure this out. Thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.