I've tried it and i still got the same error. I even dropped table1 and recreated it to include the ENGINE=InnoDB and it was successful but table2 remains unsuccessful. > Date: Tue, 7 Apr 2009 17:56:49 +0400 > From: evge...@kosov.su > To: defati...@hotmail.com > CC: mysql@lists.mysql.com > Subject: Re: PHP-MYSQL Question > > I suppose the problem is that table1.table1_id and table2.table1_id are > of different types. The first one is INT UNSIGNED and the second is just > INT. > > > abdulazeez alugo wrote: > > Table1 is as below: > > > > CREATE TABLE table1(table1_id INT UNSIGNED NOT NULL AUTO_INCREMENT, > > PRIMARY KEY(table1_id), > > entrytitle VARCHAR(100) NOT NULL, > > entrytext TEXT NOT NULL, > > entrydate TIMESTAMP NOT NULL)" ); > > > > I did not put the engine. Could that be the problem? > > > > > Date: Tue, 7 Apr 2009 17:48:16 +0400 > > > From: evge...@kosov.su > > > To: defati...@hotmail.com > > > CC: mysql@lists.mysql.com > > > Subject: Re: PHP-MYSQL Question > > > > > > # perror 150 > > > MySQL error code 150: Foreign key constraint is incorrectly formed > > > > > > What does table1 look like? > > > > > > abdulazeez alugo wrote: > > > > > > > > Yeah I used the mysql_error and it returned Can't create table > > '.\website\table2.frm' (errno: 150). So what does that say? > > > > > > > > > > > > > > > > > > > > > > > > > > > >> Date: Tue, 7 Apr 2009 17:38:59 +0400 > > > >> From: evge...@kosov.su > > > >> To: defati...@hotmail.com > > > >> CC: mysql@lists.mysql.com > > > >> Subject: Re: PHP-MYSQL Question > > > >> > > > >> Perhaps you don't have permissions to create tables? > > > >> > > > >> It would have been much clearer if your script was like this: > > > >> > > > >> $result=mysql_query($your_create_table_statement); > > > >> if($result){ print"Successful";} > > > >> else {print "Unsuccessful: ".mysql_error()} > > > >> > > > >> > > > >> abdulazeez alugo wrote: > > > >>> Hi guys, > > > >>> > > > >>> Please can anyone tell me what I'm doing wrong with the code > > below? It keep > > > >>> returning unsuccessful. > > > >>> > > > >>> $result=mysql_query("CREATE TABLE table2(table2_id INT NOT NULL > > PRIMARY KEY > > > >>> AUTO_INCREMENT, > > > >>> table1_id INT NOT NULL, > > > >>> name VARCHAR(100) NOT NULL, > > > >>> school VARCHAR(100) NOT NULL, > > > >>> comment TEXT NOT NULL, > > > >>> entrydate TIMESTAMP NOT NULL, > > > >>> FOREIGN KEY(table1_id) REFERENCES table1(table1_id)) > > > >>> ENGINE = INNODB" ); > > > >>> > > > >>> if($result){ print"Successful";} > > > >>> else {print "Unsuccessful";} > > > >>> > > > >>> Thanks in advance. Cheers. > > > >>> > > > >>> Alugo Abdulazeez. > > > >>> > > > >>> _________________________________________________________________ > > > >>> More than messages–check out the rest of the Windows Live™. > > > >>> http://www.microsoft.com/windows/windowslive/ > > > >> > > > >> -- > > > >> С уважением, > > > >> Евгений Косов > > > >> > > > >> -- > > > >> MySQL General Mailing List > > > >> For list archives: http://lists.mysql.com/mysql > > > >> To unsubscribe: > > http://lists.mysql.com/mysql?unsub=defati...@hotmail.com > > > >> > > > > > > > > _________________________________________________________________ > > > > Invite your mail contacts to join your friends list with Windows > > Live Spaces. It's easy! > > > > > > http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us > > > > > > > > > -- > > > С уважением, > > > Евгений Косов > > > > ------------------------------------------------------------------------ > > check out the rest of the Windows Live™. More than mail–Windows Live™ > > goes way beyond your inbox. More than messages > > <http://www.microsoft.com/windows/windowslive/> > > > -- > С уважением, > Евгений Косов
_________________________________________________________________ Show them the way! Add maps and directions to your party invites. http://www.microsoft.com/windows/windowslive/products/events.aspx