jhanquar has asked for the wisdom of the Perl Monks concerning the following question:

I have a form made in a html document. From there I want to acces the input of my form with the cgi module and insert these into a mongo db with the collection named experiments. The problem is when i submit my form there is a new field made in my database with all null values for the variables. Can someone help me? Thanks for your time
  • Comment on Empty variables in insertion in mongodb

Replies are listed 'Best First'.
Re: Empty variables in insertion in mongodb
by moritz (Cardinal) on Mar 01, 2011 at 15:59 UTC
Re: Empty variables in insertion in mongodb
by ig (Vicar) on Mar 01, 2011 at 18:32 UTC
Re: Empty variables in insertion in mongodb
by locked_user sundialsvc4 (Abbot) on Mar 01, 2011 at 21:28 UTC

    Step back and look at your code, and carefully consider what it is doing.

    Toolkits (like Mongo) make many things easy to specify ... some of which are sensible, and some of which are not.   It would appear to me that you have written code that restructures the table... literally, adding a new column to it.   Obviously, you don’t intend to be doing that.

    Perhaps the best advice that I can give you now is ... stop whacking your head against what you are attempting to do right now, and carefully read all of the documentation that you have.   “Google It™” to find every example that the Internet and/or PerlMonks might have to offer of “existing code that works.”   Embrace the fact that you really don’t quite know what you are doing right now ... and, without a shred of embarrassment, make it your business to discover examples that you can use to put yourself back onto your intended course.

    Been there.   Done that.   (Really!)   It’s a bit embarrassing, maybe, but ... it’s okay.   Welcome to the club.

      Mongo collections being sparse it does not make sense to keep null columns unless absolutely required we can always insert it in future via push if reqd.