473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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
Dec 11 '05 #1
19 2115
cover wrote:
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


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

Dec 11 '05 #2
Mara Guida said the following on 11/12/2005 17:31:
cover wrote:
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


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

What is your query string?



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


This is completely unrelated.

--
Oli
Dec 11 '05 #3
cover wrote:
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

Put - echo mysql_error(); - right after your query.

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************
Dec 11 '05 #4
cover wrote:
Is there a restriction to the number of fields you can work with in a
PHP to MySQL connection?


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

http://www-css.fnal.gov/dsg/external...-vs-pgsql.html

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

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

Dec 11 '05 #5
On Sun, 11 Dec 2005 18:15:52 GMT, Oli Filth <ca***@olifilth.co.uk>
wrote:

Just tried a 34-field insert; it worked fine.
Hmmm. Guess I'll keep looking for an error.

What is your query string?


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

$results = mysql_query($sqlquery);
Dec 11 '05 #6
On Sun, 11 Dec 2005 12:11:02 -0700, Chuck Anderson
<we************@seemy.sig> wrote:

Put - echo mysql_error(); - right after your query.


Thanks, I inserted it as follows:
$results = mysql_query($sqlquery);
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?
Dec 11 '05 #7
cover wrote:
On Sun, 11 Dec 2005 18:15:52 GMT, Oli Filth <ca***@olifilth.co.uk>
wrote:

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


Hmmm. Guess I'll keep looking for an error.

What is your query string?


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


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
Dec 11 '05 #8
cover wrote:
On Sun, 11 Dec 2005 12:11:02 -0700, Chuck Anderson
<we************@seemy.sig> wrote:

Put - echo mysql_error(); - right after your query.


Thanks, I inserted it as follows:
$results = mysql_query($sqlquery);
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?


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
Dec 11 '05 #9
On Mon, 12 Dec 2005 10:20:59 +1300, Chris Hope
<bl*******@electrictoolbox.com> wrote:

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.
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?
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.
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.
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', ...)
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.

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.

Dec 12 '05 #10
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.
Dec 12 '05 #11
Still having the "Column count doesn't match value count at row 1"
error - what a pain in the backside...
Dec 12 '05 #12
Check the number of fields you write after 'insert into' and after 'values' they
must be equal.
Dec 12 '05 #13
>>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.


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?
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.


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.
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', ...)


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.


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_escape_string".

Hilarion
Dec 12 '05 #14
On Mon, 12 Dec 2005 21:39:05 -0700, Christopher Pomasl
<po***********@starband.net> wrote:
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.


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
Dec 13 '05 #15
cover wrote:
On Mon, 12 Dec 2005 21:39:05 -0700, Christopher Pomasl
<po***********@starband.net> wrote:
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.


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


It's because you need to escape special characters such as single and
double quotes.

Refer to
http://www.php.net/manual/en/functio...ape-string.php
http://www.php.net/manual/en/functio...ape-string.php

You really need to be aware of sql injection:
http://www.google.com/search?q=sql+injection

It's quite possible to delete records, tables and entire databases with
sql injection. Believe me, I've done it to prove a point in the past.

--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Dec 13 '05 #16
On Sun, 11 Dec 2005 13:01:28 -0800, cover wrote:
On Sun, 11 Dec 2005 18:15:52 GMT, Oli Filth <ca***@olifilth.co.uk>
wrote:

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


Hmmm. Guess I'll keep looking for an error.

What is your query string?


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

$results = mysql_query($sqlquery);

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.

Also take heed about the unescaped variables, if that is the case.
Someone savvy enough could all sorts of fun stuff to your SQL execution.

I also always print the error along with the error SQL in the event of an
error. If the user gets it on their page, well, they weren't going
anywhere anyway and you have the diagnostics when they complain!!

Chris
Always remember, you are unique...just like everyone else.
Dec 13 '05 #17
Thanks everyone. Thanks VERY much. I've learned a lot here and
appreciate all of your posts very much. Thanks for the help.

Chris
Dec 13 '05 #18
cover,

I'm only counting 32 values in your query string (apart from the other
errors already noted) and you are stating you are doing a 34 value insert...

Norm
--
FREE Avatar hosting at www.easyavatar.com
"cover" <co****************@yahoo.com> wrote in message
news:ko********************************@4ax.com...
Still having the "Column count doesn't match value count at row 1"
error - what a pain in the backside...

Dec 14 '05 #19
"cover" <co****************@yahoo.com> wrote in message
news:0u********************************@4ax.com...
On Mon, 12 Dec 2005 10:20:59 +1300, Chris Hope
<bl*******@electrictoolbox.com> wrote:

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.


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"*


Mix-matched quotes is what's happening here - the (" double quote) is
signaling php the end of the string and it is truncating the rest of your
query. Like Hilarion said, check out escaping strings -
mysql_real_escape_string() or make sure to read up on magicquotes in your
php.ini file.

http://us3.php.net/manual/en/functio...ape-string.php <-
prefered method according to the link below
http://us3.php.net/magic_quotes/

Norm
---
FREE Avatar hosting at www.easyavatar.com
Dec 14 '05 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: abs | last post by:
Input field of the form. How to check which number this field has ? I mean the order number, like variable elementNumber in document.forms.elements ? Is it possible to check without looping and...
1
by: Larry | last post by:
There is a font number limitation in Access which prevents them from appearing on some pop-up lists. Has anybody encountered this same problem and if so is there some work-around. I do a lot of...
39
by: windandwaves | last post by:
Hi Folk I have to store up to eight boolean bits of information about an item in my database. e.g. with restaurant drive-through facility yellow windows
4
by: Chris Tate-Davies | last post by:
Hello. I have a generic table used for many different generic functions. the fields are mainly varchar's but one of these varchars contains dates (in the format dd/mm/yyyy) for one reason or...
1
by: Xaysana12345 | last post by:
Hi there, Please help, I'm absolutely stuck. I want to do MsgBox whenever number in subformfield greater than the number in mainform field or other way around, I want to happen a message says...
3
juve11
by: juve11 | last post by:
hello, i have a vb application that writes into mysql (some kind of autocomplete). problem is that it writes too many rows and the app at a moment starts to run slowly.so an option that i thaught...
1
by: cypherinfo | last post by:
Hello, I'm a newbye here and about PHP; be patient please :-) I have a mySQL table with 15000 rows; I need to populate a field of it (varchar(15)) - to be used in a way similar to a primary key -...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.