Hi,
I'm trying to do an insert with the following statement:
INSERT INTO user VALUES ( 'a*@ag.com','ag ','Aaron','Chan dler','','','La
Mirada','CA',90 638,714,'','');
and I'm getting the error message "Column count doesn't match value
count at row 1".
My table schema is:
Field Type Null Default
------------------------------------------------
email varchar(50) No
password varchar(50) No
f_name varchar(30) No
l_name varchar(40) No
address_1 varchar(50) Yes NULL
address_2 varchar(50) Yes NULL
city varchar(30) No
state char(2) No
zip mediumint(5) No 0
home_area smallint(3) No 0
home_phone varchar(7) Yes NULL
comments text Yes NULL
I have 12 fields in my table (the first being the primary key), and the
syntax seems correct here. Any ideas why this message could be appearing?
Thanks,
Aaron 5 10771
Aaron C wrote: I have 12 fields in my table (the first being the primary key), and the syntax seems correct here. Any ideas why this message could be appearing?
I don't understand that sentence. Do you have 12 or do you have 13
fields? I tested your query with 12 fields and it worked fine. If you
have an extra id field in your table, then your query won't work.
Solution in that case might be giving null as a value for that field in
your insert-sentence.
Here's what I tried:
mysql> create table user(
-> email varchar(50),
-> password varchar(50),
-> f_name varchar(30),
-> l_name varchar(40),
-> address_1 varchar(50),
-> address_2 varchar(50),
-> city varchar(30),
-> state char(2),
-> zip mediumint(5),
-> home_area smallint(3),
-> home_phone varchar(7),
-> comments text
-> );
Query OK, 0 rows affected (0.03 sec)
mysql> INSERT INTO user VALUES (
'a*@ag.com','ag ','Aaron','Chan dler','','','La Mirada','CA',90 638,714,'','');
Query OK, 1 row affected (0.00 sec)
Alright, I recreated the table in PHPMyAdmin using:
CREATE TABLE `user` (
`email` VARCHAR( 50 ) NOT NULL ,
`password` VARCHAR( 50 ) NOT NULL ,
`f_name` VARCHAR( 30 ) NOT NULL ,
`l_name` VARCHAR( 30 ) NOT NULL ,
`address_1` VARCHAR( 50 ) NOT NULL ,
`address_2` VARCHAR( 50 ) NOT NULL ,
`city` VARCHAR( 30 ) NOT NULL ,
`state` CHAR( 2 ) NOT NULL ,
`zip` MEDIUMINT( 5 ) NOT NULL ,
`home_area` SMALLINT( 3 ) NOT NULL ,
`home_phone` VARCHAR( 8 ) NOT NULL ,
`comments` TEXT NOT NULL
);
not allowing nulls for the time being.
I then executed the following:
$query = "INSERT INTO user VALUES
('x',password(' x'),'x','x','x' ,'x','x','x',11 ,11,'x','x');";
$result = mysql_query($qu ery);
if(!mysql_num_r ows($result)) echo mysql_error();
else echo "Inserted the data!";
There are 12 rows in the table, and 12 arguments passed to the INSERT
command. The types match, but I'm still getting the message "Column
count doesn't match value count at row 1". What is going on here? This
is maddening!
Thanks,
Aaron
Aggro wrote: Aaron C wrote:
I have 12 fields in my table (the first being the primary key), and the syntax seems correct here. Any ideas why this message could be appearing?
I don't understand that sentence. Do you have 12 or do you have 13 fields? I tested your query with 12 fields and it worked fine. If you have an extra id field in your table, then your query won't work. Solution in that case might be giving null as a value for that field in your insert-sentence.
Here's what I tried:
mysql> create table user( -> email varchar(50), -> password varchar(50), -> f_name varchar(30), -> l_name varchar(40), -> address_1 varchar(50), -> address_2 varchar(50), -> city varchar(30), -> state char(2), -> zip mediumint(5), -> home_area smallint(3), -> home_phone varchar(7), -> comments text -> ); Query OK, 0 rows affected (0.03 sec)
mysql> INSERT INTO user VALUES ( 'a*@ag.com','ag ','Aaron','Chan dler','','','La Mirada','CA',90 638,714,'',''); Query OK, 1 row affected (0.00 sec)
Aaron C wrote: INSERT INTO user VALUES ( 'a*@ag.com','ag ','Aaron','Chan dler','','','La Mirada','CA',90 638,714,'','');
I generally recommend naming the fields in an insert statement, in
addition to the values. That way if you add a field or change the order
of the fields your INSERT statement won't break. It sounds like exactly
that has happened in your case; there's actually more fields that the 12
values you have provided.
For example:
INSERT INTO user (email, password, f_name, l_name,
address_1, address_2, city, state, zip,
home_area, home_phone, comments)
VALUES ( 'a*@ag.com', 'ag', 'Aaron', 'Chandler',
'', '', 'La Mirada', 'CA',90638,
714, '', '');
Regards,
Bill K.
Aaron C wrote: Alright, I recreated the table in PHPMyAdmin using:
CREATE TABLE `user` (
$query = "INSERT INTO user VALUES
I tried that at both of my servers, other is 3.x and other is 4.1.7
And they both worked fine with the example queries you provided. But I
used the mysql command line tool, perhaps you should try that also?
But in case you are tired of fighting with this, you could actually try
to do it this way:
INSERT INTO user(field1, field2, ...) VALUES ('value1', 'value2', ...);
So give name for each field you are going to use. If that also fails,
try doing it again, but this time with less fields. Or start with 1
field, and then add 1 after another untill you get error. That might
help locating the problem.
Found out what it was a little bit ago...
The database name wasn't being passed properly to my db_connect()
function. Oops!
Anyway, thanks for the help, both of you.
Aaron
Aggro wrote: Aaron C wrote:
Alright, I recreated the table in PHPMyAdmin using:
CREATE TABLE `user` (
$query = "INSERT INTO user VALUES
I tried that at both of my servers, other is 3.x and other is 4.1.7
And they both worked fine with the example queries you provided. But I used the mysql command line tool, perhaps you should try that also?
But in case you are tired of fighting with this, you could actually try to do it this way:
INSERT INTO user(field1, field2, ...) VALUES ('value1', 'value2', ...);
So give name for each field you are going to use. If that also fails, try doing it again, but this time with less fields. Or start with 1 field, and then add 1 after another untill you get error. That might help locating the problem. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Chris Auer |
last post by:
I am trying to run a query where my Table and my request are variables
(Will be used in Stored Procedure)
Declare @Email VARCHAR(100)
Declare @Table VARCHAR(50)
Declare @Count VARCHAR(8)
DECLARE @cmd VARCHAR(500)
set @Table = 'tblManager'
set @Email = 'cauer@tampabay.rr.com'
|
by: Laszlo Csabi |
last post by:
Hi Folks,
Can someone explain me why I'm getting the following error?
The error message I got is : "Parameter count does not match Parameter Value count."
|
by: Dmitry V. Markin |
last post by:
Good day!
Here is my problem: I need to have a radiobutton column in my DataGrid for a
representation of a bool column, where only row can be checked at one
time(only one value in bool column can be true). So I've created a class
inheriting from DataGridColumnStyle and added the following code to the class:
protected RadioButton rb ;
....
|
by: jeguillo |
last post by:
I am trying to retrieve the text within each cell in a datagrid in
order to change the color of each cell, depending on the value within
that cell.
This works fine on the cells that are bound columns, but returns an
empty string for the cells that are hyperlink columns.
Here is the code to retrive the text:
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
|
by: tania |
last post by:
i have this table in my database:
CREATE TABLE FILM(
F_ID INT(5) NOT NULL AUTO_INCREMENT,
F_TITLE VARCHAR(40) NOT NULL,
DIRECTOR_FNAME VARCHAR(20) NOT NULL,
DIRECTOR_LNAME VARCHAR(20) NOT NULL,
TYPE VARCHAR(30) NOT NULL,
DURATION TIME ,
YEAR_RELEASE YEAR NOT NULL,
DESCRIPTION TEXT,
| |
by: Gary Wessle |
last post by:
Hi
I have a vector<charwhich looks like this (a d d d a d s g e d d d d
d k)
I need to get the biggest count of consecutive 'd'. 5 in this example
I am toying with this method but not sure if it is optimal.
thanks
int k = 0;
|
by: John |
last post by:
I just cannot manage to perform a SELECT query with NULL parameter...
My CATEGORY table does have one row where TCATEGORYPARENTID is null (real DB
null value).
TCATEGORYID and TCATEGORYPARENTID are uniqueidentifier columns.
My questions:
- is Type="Object", below, necessary?
- what shall I specify for DefaultValue in my function? I tried everything.
|
by: MP |
last post by:
vb6,ado,mdb,win2k
i pass the sql string to the .Execute method on the open connection to
Table_Name(const) db table
fwiw
(the connection opened via class wrapper:)
msConnString = "Data Source=" & msDbFilename
moConn.Properties("Persist Security Info") = False
moConn.ConnectionString = msConnString
moConn.CursorLocation = adUseClient
moConn.Mode = adModeReadWrite' or using default...same result
|
by: Byomokesh |
last post by:
Hi
I am trying to cell count and match in tgroup cols value in XML file. if cell count and tgrou cols value is mismatch, its showing error.
My xml
--------------
<tgroup cols="3">
<colspec colnum="1" colname="col1"/>
<colspec colnum="2" colname="col2"/>
<colspec colnum="3" colname="col3"/>
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |