PDA

View Full Version : MySql syntax error, HELP


sam_z84
04-19-2007, 09:31 AM
Hi guys,
I hope this post gets some attention.
I was setting up a database, and i imported the database.sql file to my database through my phpmyadmin and I get the following:

-- phpMyAdmin SQL Dump
-- version 2.6.0-pl3
-- [www.phpmyadmin.net]
--
-- Host: localhost
-- Generation Time: Jul 10, 2005 at 02:00 PM
-- Server version: 4.0.22
-- PHP Version: 4.3.9
--
-- Database: `yourdatabase_asb`
--
-- --------------------------------------------------------
--
-- Table structure for table `asb_articles`
--
DROP TABLE IF EXISTS `asb_articles` ;

CREATE TABLE `asb_articles` (

`id` int( 255 ) NOT NULL AUTO_INCREMENT ,
`url` varchar( 255 ) NOT NULL default '',
`title` longtext NOT NULL ,
`author` varchar( 200 ) NOT NULL default '',
`article` longtext NOT NULL ,
`resource_box` longtext NOT NULL ,
`category` varchar( 255 ) NOT NULL default '',
PRIMARY KEY ( `id` ) ,
UNIQUE KEY `url` ( `url` ) ,
FULLTEXT KEY `article` ( `article` )
) TYPE = MYISAM AUTO_INCREMENT =1;



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 'id` int(255) NOT NULL auto_increment,
`url` varchar(255) NOT NULL default '',
' at line 1

HELP MEEE !!!

Thanks in advance for your help

myusuf
04-19-2007, 12:42 PM
mysql> CREATE TABLE `asb_articles` (
->
-> `id` int( 255 ) NOT NULL AUTO_INCREMENT ,
-> `url` varchar( 255 ) NOT NULL default '',
-> `title` longtext NOT NULL ,
-> `author` varchar( 200 ) NOT NULL default '',
-> `article` longtext NOT NULL ,
-> `resource_box` longtext NOT NULL ,
-> `category` varchar( 255 ) NOT NULL default '',
-> PRIMARY KEY ( `id` ) ,
-> UNIQUE KEY `url` ( `url` ) ,
-> FULLTEXT KEY `article` ( `article` )
-> ) TYPE = MYISAM AUTO_INCREMENT =1;
Query OK, 0 rows affected, 1 warning (0.03 sec)

mysql> show warnings;
+---------+------+--------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+--------------------------------------------------------------------------+
| Warning | 1287 | 'TYPE=storage_engine' is deprecated; use 'ENGINE=storage_engine' instead |
+---------+------+--------------------------------------------------------------------------+
1 row in set (0.00 sec)

myusuf
04-19-2007, 12:44 PM
http://dev.mysql.com/doc/refman/4.1/en/example-auto-increment.html
http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

guelphdad
04-19-2007, 02:39 PM
INT(255) is wrong you only want INT see this article (http://guelphdad.wefixtech.co.uk/sqlhelp/numericdata.shtml) for details.

sam_z84
04-20-2007, 04:42 AM
hey guys, thanx for the help, but now i still get pretty much the same error..:confused:

DROP TABLE IF EXISTS `asb_articles` ;

CREATE TABLE `asb_articles` (

`id` int NOT NULL AUTO_INCREMENT ,
`url` varchar( 255 ) NOT NULL default '',
`title` longtext NOT NULL ,
`author` varchar( 200 ) NOT NULL default '',
`article` longtext NOT NULL ,
`resource_box` longtext NOT NULL ,
`category` varchar( 255 ) NOT NULL default '',
PRIMARY KEY ( `id` ) ,
UNIQUE KEY `url` ( `url` ) ,
FULLTEXT KEY `article` ( `article` )
) TYPE = MYISAM AUTO_INCREMENT =1;


#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 'id`int NOT NULL auto_increment,
`url` varchar(255) NOT NULL default '',
`tit' at line 1

guelphdad
04-20-2007, 03:21 PM
try it like this:


CREATE TABLE `asb_articles` (

`id` int NOT NULL AUTO_INCREMENT primary key,
`url` varchar( 255 ) NOT NULL default '',
`title` longtext NOT NULL ,
`author` varchar( 200 ) NOT NULL default '',
`article` longtext NOT NULL ,
`resource_box` longtext NOT NULL ,
`category` varchar( 255 ) NOT NULL default '',
UNIQUE KEY `url` ( `url` ) ,
FULLTEXT KEY `article` ( `article` )
) TYPE = MYISAM AUTO_INCREMENT =1;

sam_z84
04-21-2007, 01:41 AM
thank you for spending this much time on this.. unfortunatly it is still giving me the same error.. so i'm not really sure why it's doin this or if i even should continue or not?

If you got anyother advice, throw em at me plz, if not dont waste ur time with it

regards and many thanks for all of your help guys :o

guelphdad
04-21-2007, 01:59 AM
are you creating this table directly in the mysql client? or are you using php or phpmyadmin or anything like that? the table creates fine for me.

try creating the table with only the first column and if it creates, drop the table and add two columns when you try again to see if you get .

sam_z84
04-21-2007, 10:50 PM
hi,
i'm using phpmyadmin.. i go on "import" choose the file and then i get that error.. so u did that and it worked for u?

so u suggest i manually create the table?

guelphdad
04-22-2007, 02:09 AM
in phpmyadmin, there is a tab labelled SQL. click that tab and then try to create your table there.

note that phpmyadmin is only one of several GUIs that can be used with mysql. you can also use an array of programming applications like php, coldfusion, asp etc. etc. to interface with mysql.

unless you are directly accessing the mysql client then you should note that when you continue to have problems with something you are being helped with.

the issue could easily be phpmyadmin and the import.