zed420 Posted October 16, 2008 Share Posted October 16, 2008 Hi All Can some one please tell me what is wrong with these two tables that I've created each time I'm dropping them into database this error keeps coming up; #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 'FOREIGN KEY (user_id) REFERENCES user(id) ) ENGINE=MyISAM DEFAULT CHARSET=lat' at line 30 DROP TABLE user; CREATE TABLE `user` ( `id` smallint(5) unsigned NOT NULL auto_increment, `fullname` varchar(60) NOT NULL, `username` char(15) NOT NULL, `pswd` char(32) NOT NULL, `address` varchar(70) NOT NULL, `post_code` varchar(10) NOT NULL, `tel` int(11) NULL, `mobile` char(40) NOT NULL, `email` char(55) NOT NULL, `profile` char(255) NOT NULL, PRIMARY KEY (`id`)); DROP TABLE job_tb; CREATE TABLE `job_tb` ( `job_id` tinyint(4) NOT NULL auto_increment, `user_id` int default NULL, `typeOfbooking` char(10) default NULL, `typeOfcustomer` char(10) default NULL, `typeOfvehicle` char(20) default NULL, `noOfVehicle` char(10) default NULL, `regul` char(20) default NULL, `mon` char(5) default NULL, `tue` char(5) default NULL, `wed` char(5) default NULL, `thur` char(5) default NULL, `fri` char(5) default NULL, `sat` char(5) default NULL, `sun` char(5) default NULL, `cust_name` varchar(40) NOT NULL, `cust_address` varchar(60) NOT NULL, `post_code` varchar(12) default NULL, `cust_tel` int(11) NOT NULL, `email` varchar(60) NOT NULL, `des` varchar(50) NOT NULL, `reqVehicle` char(10) default NULL, `dateDay` tinyint(2) default NULL, `dateMO` tinyint(12) default NULL, `dateYr` mediumint(5) default NULL, `timeHr` tinyint(2) default NULL, `timeMin` tinyint(2) default NULL, `comment` varchar(255) default NULL, PRIMARY KEY (`job_id`) FOREIGN KEY (user_id) REFERENCES user(id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ; Thanks Zed Quote Link to comment https://forums.phpfreaks.com/topic/128674-solved-foreign-key-problem/ Share on other sites More sharing options...
fenway Posted October 16, 2008 Share Posted October 16, 2008 You're missing a comma between PRIMARY KEY ... and FOREIGN KEY. Quote Link to comment https://forums.phpfreaks.com/topic/128674-solved-foreign-key-problem/#findComment-667129 Share on other sites More sharing options...
zed420 Posted October 16, 2008 Author Share Posted October 16, 2008 Thank you blue, I spent all night Zed Quote Link to comment https://forums.phpfreaks.com/topic/128674-solved-foreign-key-problem/#findComment-667166 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.