MySQL syntax question


#1

I am having trouble with MySQL and could really use help. It is causing issues when I try to export the structure and I assume is also the reason that I can’t use PHP to insert new records.

When I use PHP Myadmin to export the structure of the table and then try and run that script on another database (also using PHP MyAdmin) I get an error. Here is the SQL generated (and therefore the table format):

[code]# phpMyAdmin MySQL-Dump

version 2.4.0

http://www.phpmyadmin.net/ (download page)

Host: localhost

Generation Time: May 25, 2004 at 12:53 PM

Server version: 4.0.16

PHP Version: 4.3.4

Database : marriage_gay

--------------------------------------------------------

Table structure for table links

CREATE TABLE linksxx (
id int(10) NOT NULL auto_increment,
name varchar(50) default NULL,
url varchar(50) default NULL,
group varchar(50) default NULL,
category varchar(50) default NULL,
description varchar(255) default NULL,
contact varchar(40) default NULL,
email varchar(40) default NULL,
phone varchar(30) default NULL,
notes varchar(255) default NULL,
PRIMARY KEY (id),
UNIQUE KEY id (id)
) TYPE=MyISAM;[/code]

Here is the error that PHP MyAdmin gives me when I run the above sql:

[code]MySQL said:

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 'GROUP varchar( 50 ) default NULL , category varchar( 50 ) def[/code]

Please help me understand what the issue is and how I can fix it.

Thanks
Peter


#2

Group is a reserved word in mysql, and most sql dbs. You can either put backticks around the field name or better yet, rename it. It’s not good practice to use reserved words.

Keith


#3

GRP is nice replacement for GROUP.