Field Number Limitation into MySQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cover

    Field Number Limitation into MySQL

    Is there a restriction to the number of fields you can work with in a
    PHP to MySQL connection? I'd used as many as 15 quite a few times and
    now I have a form with 34 fields and can't seem to get the info
    inserted into the table even though I'm not getting any connection
    errors, etc. Since my method is identical, I'm wondering if there's
    some 'rule' I am unaware of. TIA
  • Mara Guida

    #2
    Re: Field Number Limitation into MySQL

    cover wrote:[color=blue]
    > Is there a restriction to the number of fields you can work with in a
    > PHP to MySQL connection? I'd used as many as 15 quite a few times and
    > now I have a form with 34 fields and can't seem to get the info
    > inserted into the table even though I'm not getting any connection
    > errors, etc. Since my method is identical, I'm wondering if there's
    > some 'rule' I am unaware of. TIA[/color]

    GET vs POST? See the thread titled "Memory Limit for for HTML pages??"

    Comment

    • Oli Filth

      #3
      Re: Field Number Limitation into MySQL

      Mara Guida said the following on 11/12/2005 17:31:[color=blue]
      > cover wrote:
      >[color=green]
      >>Is there a restriction to the number of fields you can work with in a
      >>PHP to MySQL connection? I'd used as many as 15 quite a few times and
      >>now I have a form with 34 fields and can't seem to get the info
      >>inserted into the table even though I'm not getting any connection
      >>errors, etc. Since my method is identical, I'm wondering if there's
      >>some 'rule' I am unaware of. TIA[/color]
      >[/color]

      Just tried a 34-field insert; it worked fine.

      What is your query string?




      [color=blue]
      >
      > GET vs POST? See the thread titled "Memory Limit for for HTML pages??"
      >[/color]

      This is completely unrelated.

      --
      Oli

      Comment

      • Chuck Anderson

        #4
        Re: Field Number Limitation into MySQL

        cover wrote:
        [color=blue]
        >Is there a restriction to the number of fields you can work with in a
        >PHP to MySQL connection? I'd used as many as 15 quite a few times and
        >now I have a form with 34 fields and can't seem to get the info
        >inserted into the table even though I'm not getting any connection
        >errors, etc. Since my method is identical, I'm wondering if there's
        >some 'rule' I am unaware of. TIA
        >
        >[/color]
        Put - echo mysql_error(); - right after your query.

        --
        *************** **************
        Chuck Anderson • Boulder, CO

        Integrity is obvious.
        The lack of it is common.
        *************** **************

        Comment

        • Toby Inkster

          #5
          Re: Field Number Limitation into MySQL

          cover wrote:
          [color=blue]
          > Is there a restriction to the number of fields you can work with in a
          > PHP to MySQL connection?[/color]

          Do you mean a limit to the number of columns that a table can contain in
          MySQL?



          | MySQL: Maximum number of columns in one table - 3398

          --
          Toby A Inkster BSc (Hons) ARCS
          Contact Me ~ http://tobyinkster.co.uk/contact

          Comment

          • cover

            #6
            Re: Field Number Limitation into MySQL

            On Sun, 11 Dec 2005 18:15:52 GMT, Oli Filth <catch@olifilth .co.uk>
            wrote:
            [color=blue]
            >
            >Just tried a 34-field insert; it worked fine.[/color]

            Hmmm. Guess I'll keep looking for an error.
            [color=blue]
            >
            >What is your query string?
            >[/color]

            $sqlquery = "INSERT INTO $table VALUES('$id', '$etype', '$area',
            '$equipname', '$jdeno', '$equipno', '$mccloc', '$bspec', '$bsize',
            '$bfpm', '$gbmanu', '$lube', '$gbsize', '$gbratio', '$motorsize',
            '$motorframe', '$drivesprocket ', '$drivensprocke t', '$chainsize',
            '$lacingtype', '$brgtypesize', '$brgqty', '$tbrgtypesize' , '$tbrgqty',
            '$headsize', '$hoawidth', '$tailsize', '$toawidth', '$cbsize',
            '$keysize' '$uhmwsize', '$convnotes',)" ;

            $results = mysql_query($sq lquery);

            Comment

            • cover

              #7
              Re: Field Number Limitation into MySQL

              On Sun, 11 Dec 2005 12:11:02 -0700, Chuck Anderson
              <websiteaddress @seemy.sig> wrote:

              [color=blue]
              >Put - echo mysql_error(); - right after your query.[/color]

              Thanks, I inserted it as follows:
              $results = mysql_query($sq lquery);
              echo mysql_error();
              mysql_close();

              and received the following error :
              "Column count doesn't match value count at row 1"

              looked at the database again and field lengths were okay to accomodate
              variable content - thoughts?

              Comment

              • Chris Hope

                #8
                Re: Field Number Limitation into MySQL

                cover wrote:
                [color=blue]
                > On Sun, 11 Dec 2005 18:15:52 GMT, Oli Filth <catch@olifilth .co.uk>
                > wrote:
                >[color=green]
                >>
                >>Just tried a 34-field insert; it worked fine.[/color]
                >
                > Hmmm. Guess I'll keep looking for an error.
                >[color=green]
                >>
                >>What is your query string?[/color]
                >
                > $sqlquery = "INSERT INTO $table VALUES('$id', '$etype', '$area',
                > '$equipname', '$jdeno', '$equipno', '$mccloc', '$bspec', '$bsize',
                > '$bfpm', '$gbmanu', '$lube', '$gbsize', '$gbratio', '$motorsize',
                > '$motorframe', '$drivesprocket ', '$drivensprocke t', '$chainsize',
                > '$lacingtype', '$brgtypesize', '$brgqty', '$tbrgtypesize' , '$tbrgqty',
                > '$headsize', '$hoawidth', '$tailsize', '$toawidth', '$cbsize',
                > '$keysize' '$uhmwsize', '$convnotes',)" ;[/color]

                There's a comma before the closing bracket. I would say that's your
                error. echo mysql_error() after running the query and see what happens.
                Or alternatively echo out the sql string and paste it into the mysql
                console or phpMyAdmin etc.

                One other thing, where do all those values come from? Directly from the
                form with no escaping? If so, you need to read up on the topic of sql
                injection.

                And one other thing... I personally believe you are better to write your
                insert query in the form:

                INSERT INTO tablename (fieldname1, fieldname2, ... ) VALUES ('value1',
                'value2', ...)

                than not specity the fieldnames. Sure, it takes time to write your
                query, but if you add a column to the table at a later time you will
                break any existing insert queries for that table as the number of
                columns specified in your query won't match the number in the table.

                --
                Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com

                Comment

                • Chris Hope

                  #9
                  Re: Field Number Limitation into MySQL

                  cover wrote:
                  [color=blue]
                  > On Sun, 11 Dec 2005 12:11:02 -0700, Chuck Anderson
                  > <websiteaddress @seemy.sig> wrote:
                  >
                  >[color=green]
                  >>Put - echo mysql_error(); - right after your query.[/color]
                  >
                  > Thanks, I inserted it as follows:
                  > $results = mysql_query($sq lquery);
                  > echo mysql_error();
                  > mysql_close();
                  >
                  > and received the following error :
                  > "Column count doesn't match value count at row 1"
                  >
                  > looked at the database again and field lengths were okay to accomodate
                  > variable content - thoughts?[/color]

                  It means you have eg 35 columns in your database but your sql string
                  only has values for 34 of them. See the other message I just posted a
                  couple of minutes ago.

                  --
                  Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com

                  Comment

                  • cover

                    #10
                    Re: Field Number Limitation into MySQL

                    On Mon, 12 Dec 2005 10:20:59 +1300, Chris Hope
                    <blackhole@elec trictoolbox.com > wrote:

                    [color=blue]
                    >There's a comma before the closing bracket. I would say that's your
                    >error. echo mysql_error() after running the query and see what happens.
                    >Or alternatively echo out the sql string and paste it into the mysql
                    >console or phpMyAdmin etc.[/color]

                    caught the comma after installing the echo mysql_error(); line and now
                    have:
                    "You have an error in your SQL syntax; check the manual that
                    corresponds to your MySQL server version for the right syntax to use
                    near 'x 2" x .25', 'no notes')' at line 1" unless I remove the
                    measurements from the uhmwsize field which were 60' x 2" x .25"*

                    after blanking that field, the error came back to a more simple
                    "Column count doesn't match value count at row 1" which now makes me
                    wonder... Setting id as an integer when establishing the database,
                    what numerical entry should I enter into that?
                    [color=blue]
                    >One other thing, where do all those values come from? Directly from the
                    >form with no escaping? If so, you need to read up on the topic of sql
                    >injection.[/color]

                    I use two forms to enter the data and until now, it's worked very well
                    (so far with fields of 12 or less). One form is the user input, the
                    second does the query and insert while echoing the values to the
                    screen of what the user just entered into the database.
                    [color=blue]
                    >And one other thing... I personally believe you are better to write your
                    >insert query in the form:
                    >
                    >INSERT INTO tablename (fieldname1, fieldname2, ... ) VALUES ('value1',
                    >'value2', ...)[/color]

                    I've done it this way too - kind of got away from it which may have
                    been bad however, went back to it for this error solving and it made
                    no difference in the outcome or error.
                    [color=blue]
                    >
                    >than not specity the fieldnames. Sure, it takes time to write your
                    >query, but if you add a column to the table at a later time you will
                    >break any existing insert queries for that table as the number of
                    >columns specified in your query won't match the number in the table.[/color]

                    Comment

                    • cover

                      #11
                      Re: Field Number Limitation into MySQL

                      Another thing I tried was entering into a MyISAM table rather than an
                      InnoDB (in hopes of establishing a difference in the symptoms as I was
                      trying to check out the size/memory thing). No change.

                      Comment

                      • cover

                        #12
                        Re: Field Number Limitation into MySQL

                        Still having the "Column count doesn't match value count at row 1"
                        error - what a pain in the backside...

                        Comment

                        • %u Saurabh Periwal

                          #13
                          Re: Field Number Limitation into MySQL

                          Check the number of fields you write after 'insert into' and after 'values' they
                          must be equal.

                          Comment

                          • Hilarion

                            #14
                            Re: Field Number Limitation into MySQL

                            >>There's a comma before the closing bracket. I would say that's your[color=blue][color=green]
                            >>error. echo mysql_error() after running the query and see what happens.
                            >>Or alternatively echo out the sql string and paste it into the mysql
                            >>console or phpMyAdmin etc.[/color]
                            >
                            > caught the comma after installing the echo mysql_error(); line and now
                            > have:
                            > "You have an error in your SQL syntax; check the manual that
                            > corresponds to your MySQL server version for the right syntax to use
                            > near 'x 2" x .25', 'no notes')' at line 1" unless I remove the
                            > measurements from the uhmwsize field which were 60' x 2" x .25"*
                            >
                            > after blanking that field, the error came back to a more simple
                            > "Column count doesn't match value count at row 1" which now makes me
                            > wonder... Setting id as an integer when establishing the database,
                            > what numerical entry should I enter into that?
                            >[color=green]
                            >>One other thing, where do all those values come from? Directly from the
                            >>form with no escaping? If so, you need to read up on the topic of sql
                            >>injection.[/color]
                            >
                            > I use two forms to enter the data and until now, it's worked very well
                            > (so far with fields of 12 or less). One form is the user input, the
                            > second does the query and insert while echoing the values to the
                            > screen of what the user just entered into the database.
                            >[color=green]
                            >>And one other thing... I personally believe you are better to write your
                            >>insert query in the form:
                            >>
                            >>INSERT INTO tablename (fieldname1, fieldname2, ... ) VALUES ('value1',
                            >>'value2', ...)[/color]
                            >
                            > I've done it this way too - kind of got away from it which may have
                            > been bad however, went back to it for this error solving and it made
                            > no difference in the outcome or error.[/color]



                            You definitely have to read about value escaping and SQL injection.
                            One (or more) of the values you are placing in your query contains
                            apostrophe sign. This makes query which looks like that:

                            $qry = "INSERT INTO tablename VALUES ( '$some_value' )"

                            look like that (for $some_value == "John's deep"):

                            INSERT INTO tablename VALUES 'John's deep'

                            The apostrophe contained in the value is recognized as the string value
                            terminator. This causes syntax error in this case. If the user notices
                            that he's values break the script, then he can realize that your
                            script is vulnerable to SQL injection and enter value which will
                            make $some_value == "'; DROP TABLE tablename;" which in turn will make
                            the query look like this:

                            INSERT INTO tablename VALUES ''; DROP TABLE tablename;

                            which will make the insert and drop the table.

                            Again, as Chris suggested: read about SQL injection and start using
                            functions like "mysql_real_esc ape_string".

                            Hilarion

                            Comment

                            • cover

                              #15
                              Re: Field Number Limitation into MySQL

                              On Mon, 12 Dec 2005 21:39:05 -0700, Christopher Pomasl
                              <pomasl-NOSpam@starband .net> wrote:
                              [color=blue]
                              >Someone already noted the extra comma at the end before the close paren.
                              >You are also, seemingly, missing a comma between keisize and uhmwsize in
                              >the last line.[/color]

                              WOW - that was it and how did I miss it? thanks very much and thanks
                              to everyone who replied and helped me with this...

                              One question - as I used the indicator for feet and inches (' and "
                              respectively), I received error codes in the query. Is there a way to
                              tell MySQL to ignore feet or inch inputs when they're inserted through
                              the form? TIA

                              Comment

                              Working...