For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > August 2004 > Problem creating a table in PHPmyadmin









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Problem creating a table in PHPmyadmin
Perfidus

2004-08-18, 3:57 pm

I'm trying to create a table from phpmyadmin, the table is created
but it stumbles when trying to ad the first

--------
CREATE TABLE leche2 ( Id INT , Campo2 VARCHAR(255) ,
Campo3 INT , Campo4 VARCHAR(255) , Campo5 DOUBLE ,
Campo6 INT , Campo7 VARCHAR(50) , Campo8 DOUBLE ,
Campo9 DOUBLE , Campo18 DOUBLE , Campo17 DOUBLE , Campo16
VARCHAR(50) , Campo15 INT , Campo14 VARCHAR(50)
, Campo13 VARCHAR(50) , Campo12 VARCHAR(50) , Campo11
INT , Campo10 VARCHAR(255),KEY Id(Id) );


INSERT INTO leche2 VALUES (
10001,"FONDO PESCADOR EXTRA",40000105,"leches de galicia
S.L.",2,64,15,"RED",1000,8,11,85,0,"U1C8",1,"PF","M","C",60111001,"FONDOS
DE GRUPO"
);
--------

The error message:

--------
consulta SQL :

INSERT INTO leche2
VALUES (

10001, "FONDO PESCADOR EXTRA", 40000105, "ARROCERIAS DE
ALICANTE S.L.", 2, 64, 15, "RED", 1000, 8, 11, 85, 0,
"U1C8", 1, "PF", "M", "C", 60111001,
"FONDOS DE GRUPO TAPELIA"
)

MySQL ha dicho:


Column count doesn't match value count at row 1
--------

Any hints??



----------------------------------------
The post originated from PHP Freaks:
----------------------------------------
http://www.phpfreaks.com
http://www.phpfreaks.com/forums


mushroom

2004-08-18, 3:57 pm

I belive each of your values (even the numbers) should be inclosed in
single not double quotes.



----------------------------------------
The post originated from PHP Freaks:
----------------------------------------
http://www.phpfreaks.com
http://www.phpfreaks.com/forums


Arenium

2004-08-18, 3:57 pm

Yes, yes, yes, yes, yes. From a security standpoint, all strings as
well as floats or ints (all numbers in general) should be enclosed in
single-quotes. Read more
http://dev.mysql.com/doc/mysql/en/S...uidelines.html.

"Tell a man there are 300 billion stars in the
universe and he'll believe you.
Tell him a bench has wet paint on it and he'll have to touch to
be sure."
---
http://php.net/manual | http://dev.mysql.com/doc/mysql/ |
http://httpd.apache.org/docs-2.0/ | http://gentoo.org
---
http://php.net/manual/en/security.index.php |
http://forums.devshed.com/t165947/s.html |
http://www.asleep.net/hacking/php/style/
---
http://www.phpfreaks.com/forums/index.php?showtopic=31047 |
http://www.phpfreaks.com/forums/ind...?showtopic=6264 |
http://www.phpfreaks.com/tutorial_index.php
---
Official Linux registered user
http://counter.li.org/


----------------------------------------
The post originated from PHP Freaks:
----------------------------------------
http://www.phpfreaks.com
http://www.phpfreaks.com/forums


steve

2004-08-18, 8:56 pm

"Perfidus" wrote:
> I’m trying to create a table from phpmyadmin, the table is
> created
> but it stumbles when trying to ad the first
>
> --------
> CREATE TABLE leche2 ( Id INT , Campo2 VARCHAR(255) ,
> Campo3 INT , Campo4 VARCHAR(255) , Campo5 DOUBLE ,
> Campo6 INT , Campo7 VARCHAR(50) , Campo8 DOUBLE ,
> Campo9 DOUBLE , Campo18 DOUBLE , Campo17 DOUBLE , Campo16
> VARCHAR(50) , Campo15 INT , Campo14 VARCHAR(50)
> , Campo13 VARCHAR(50) , Campo12 VARCHAR(50) , Campo11
> INT , Campo10 VARCHAR(255),KEY Id(Id) );
>
>
> INSERT INTO leche2 VALUES (
> 10001,"FONDO PESCADOR EXTRA",40000105,"leches de galicia
>

S.L.",2,64,15,"RED",1000,8,11,85,0,"U1C8",1,"PF","M","C",60
111
> 001,"FONDOS
> DE GRUPO"
> );
> --------
>
> The error message:
>
> --------
> consulta SQL :
>
> INSERT INTO leche2
> VALUES (
>
> 10001, "FONDO PESCADOR EXTRA", 40000105, "ARROCERIAS DE
> ALICANTE S.L.", 2, 64, 15, "RED", 1000, 8, 11, 85, 0,
> "U1C8", 1, "PF", "M", "C", 60111001,
> "FONDOS DE GRUPO TAPELIA"
> )
>
> MySQL ha dicho:
>
>
> Column count doesn’t match value count at row 1
> --------
>
> Any hints??
>
>
>
> ----------------------------------------
> The post originated from PHP Freaks:
> ----------------------------------------
> http://www.phpfreaks.com
> http://www.phpfreaks.com/forums


I think mysql is getting about what columns are accepting
what values.

It is ALWAYS better to do:
insert into tablename (cola, colb, colc) values (’xx’, ’yy’, ’zz’)

Also note that for your auto-increment field, you don’t need to input
any value, although it would accept it if you push a value in there
that is unique.

I suggest that you do an insert with phpmyadmin itself. Then look at
the sql command that is generated.

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-SQL-Pro...pict140920.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=471681
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com