Chmrr is correct. In order for SQL to know what columns your are inserting into, you have to name them.  INSERT INTO Table VALUES (?,?) isn't sufficient. You need to specify the fields, via   INSERT INTO Table (a, b) VALUES (?,?) Think of it as a list of associations, but with an array of keys on the left, and an array of values (or placeholders) on the right.


Update: According the the MySQL doc for INSERT, the column names are indeed optional. This is a bad practice, however, since it will break your code whenever you change a table. My recommendation is to always explicitly name columns.


In reply to Re: Re: Inserting values into a MySQL database by dws
in thread Inserting values into a MySQL database by TStanley

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.