6

I am working on my forums website earlier this month and came across a little problem. Unfortunately, everything has gone smoothly except for my database. I was making a table in it called users with this script...

CREATE TABLE `users` (
`id` int(4) NOT NULL auto_increment,
`username` varchar(65) NOT NULL default '',
`password` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;

When I tried to run the code however, I get this error...

#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 'TYPE=MyISAM AUTO_INCREMENT=2' at line 6

I have dealt with this once before by running it with Engine, but I got two different errors when I did that this time.

I did some research on it and thought my MySQL code may be outdated, but when I ran the code on the same version of MySQL from my one of my employees computers, it worked fine. After that, I tried running it on an older version of MySQL from my computer again, but still got an error.

My assumption is it may be a simple mistake, or a computer/server error. I would try to just do my website on a different computer, speaking that I own a computer shop, but I don't want to have to start all over since it is localhost. Also, I am at a loss for flash drives and with the weather we have been getting out here in north Scandinavia, there is no way I will be able to get it shipped any time soon.

So, as a last resort I decided to ask you guys. Help is appreciated.

PCJackson
  • 76
  • 1
  • 1
  • 7
  • I'll try it again, but the first time I tried I got two different errors – PCJackson Feb 21 '14 at 15:00
  • what errors do you get? – Sam Feb 21 '14 at 15:01
  • Strange ones such as Users is already a table in the database, even if it is a new clean database. I have never seen anything like it – PCJackson Feb 21 '14 at 15:04
  • can you post the errors? – Sam Feb 21 '14 at 15:05
  • Like I said, I ran the same version of everything on my employees computer, and it worked fine... – PCJackson Feb 21 '14 at 15:05
  • you already have a 'Users' table in the database. – Sam Feb 21 '14 at 15:06
  • Sorry, I know that would help #1050 - Table 'users' already exists – PCJackson Feb 21 '14 at 15:06
  • already have that table too then. – Sam Feb 21 '14 at 15:07
  • I would show the other one but I fixed it so I am not worried about that – PCJackson Feb 21 '14 at 15:07
  • it seems like you already have the tables you are trying to create – Sam Feb 21 '14 at 15:07
  • @Sam D thanks for your help, I at least know what the problem is. Never heard of it before, gonna be a pain to find it, but at least I know that for some reason when I create a database it is automatically creating a table. I would think this is impossible unless, my php script allows it to do so. Do you think I should ask, another question about it or do you think you know how to fix? – PCJackson Feb 21 '14 at 15:15

2 Answers2

7

you must change this

  TYPE=MyISAM

to

 ENGINE=MyISAM

TYPE was deprecated in MySQL 4.0 and removed in MySQL 5.5.

documentation http://dev.mysql.com/doc/refman/5.6/en/create-table.html

echo_Me
  • 37,078
  • 5
  • 58
  • 78
0
CREATE TABLE `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(45) NOT NULL,
  `password` varchar(45) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
James
  • 9,694
  • 5
  • 32
  • 38