mysql-front error

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
kumarsena
Forum Newbie
Posts: 18
Joined: Mon Oct 20, 2003 7:18 am
Contact:

mysql-front error

Post by kumarsena »

hey

im using mysl frontend to crete a databse and im trying to insert fields in the tabel but i get the following error.
i tried to insert a field called albumName with type TEXT value 35 and default 0

any help, please!!

1064 - 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 '(35) DEFAULT '0')' at line 1

thanks
kumar
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

I don't know if you can have a field of type text with a default value.

You might have to make the field a varchar instead.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

can you show us the query statement you are using ?
kumarsena
Forum Newbie
Posts: 18
Joined: Mon Oct 20, 2003 7:18 am
Contact:

Post by kumarsena »

got it sorted guys. i just had to remove the length/set atribute. im not sure what this is for, but without is it works fine...can anyine tell what the lenght/set is for?

thnx
kumar
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

length is for the amount of characters in the variable

ie. length of 3 means you can have bobby (5 chars), they'd have to do bob (3 chars), etc
kumarsena
Forum Newbie
Posts: 18
Joined: Mon Oct 20, 2003 7:18 am
Contact:

Post by kumarsena »

tnx
xinelo
Forum Newbie
Posts: 5
Joined: Thu Nov 20, 2003 8:57 pm

Post by xinelo »

hello.

i´ve got the same problem. i tried removing the length attribute but still it doesn´work

i´m running easyphp1-7 (mysql 4.0.15, php 4.3.3 and apache 1.3.27) under windows XP

thanks for reading, i hope someone can help

and this is what i get

Error

SQL-query :

CREATE TABLE 't_termino'(
'cle_fr'varchar( 250 ) ,
'gram_fr'varchar( 250 ) ,
'src_cle_fr'varchar( 250 ) ,
'var_fr'varchar( 250 ) ,
'syn_fr'varchar( 250 ) ,
'autre_forme_fr'varchar( 250 ) ,
'gram_autre_forme_fr'varchar( 250 ) ,
'nt_fr'text,
'src_nt_fr'varchar( 250 ) ,
'nl_fr'text,
'src_nl_fr'varchar( 250 ) ,
'cle_en'varchar( 250 ) ,
'gram_en'varchar( 10 ) ,
'src_cle_en'varchar( 250 ) ,
'var_en'varchar( 250 ) ,
'syn_en'varchar( 250 ) ,
'autre_forme_en'varchar( 250 ) ,
'gram_autre_forme_en'varchar( 250 ) ,
'nt_en'text,
'src_nt_en'varchar( 250 ) ,
'nl_en'text,
'src_nl_en'varchar( 250 ) ,
'++'varchar( 250 ) ,
'code_op_fr'varchar( 250 ) ,
'code_op_en'varchar( 250 ) ,
'champ'varchar( 250 ) ,
'combinatoire_fr'text,
'combinatoire_en'text,
'valideur_en'varchar( 250 ) ,
'valideur_fr'varchar( 250 ) ,
'domaine'varchar( 250 ) ,
'fiche_douteuse'char( 1 ) NOT NULL default ''
) TYPE = MYISAM

MySQL said:

#1064 - 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 ''t_termino'( 'cle_fr'varchar( 250 ) ,
'gram_fr'varchar( 250
kumarsena
Forum Newbie
Posts: 18
Joined: Mon Oct 20, 2003 7:18 am
Contact:

Post by kumarsena »

hey,

anyone who help xinelo...?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

You have to enclose your field names into backticks (`) and do not forget spaces after field name:

Code: Select all

//was
'cle_fr'varchar( 250 ) ,
//should be
`cle_fr` varchar( 250 ) ,
Table name should be enclosed into backticks also:

Code: Select all

//was
CREATE TABLE 't_termino'(
//should be
CREATE TABLE `t_termino`(
xinelo
Forum Newbie
Posts: 5
Joined: Thu Nov 20, 2003 8:57 pm

alright!

Post by xinelo »

thanks you both, weirdan and kumarsena

it works now, using backticks... however i do include a space after fields names, but what i posted is what phpmyadmin returns with the error message

so i actually input:

'cle_fr' varchar(250),

and got (on the error message):


'cle_fr'varchar( 250 ) ,

that is, no space between the field name and the attribute and extra spaces between the length, the brackets and even the comma. weird...

but hey, it works now, thanks a lot! :D
Post Reply