good day! im an IT student. im new to php&mysql. my database engine is first myisam. everything works fine. but when i changed it into innodb(for foreign key purposes) i can't insert a data in my the parent table. i can insert data in child table though. replies are really appreciated! help me pls.!

Recommended Answers

All 3 Replies

good day! im an IT student. im new to php&mysql. my database engine is first myisam. everything works fine. but when i changed it into innodb(for foreign key purposes) i can't insert a data in my the parent table. i can insert data in child table though. replies are really appreciated! help me pls.!

I believe that which database engine a table uses is determined for each table, not for the entire database. When you create a table without specifying the database engine the table uses myisam by default. Are you sure you changed both your parent and your child table to innodb (you say you changed "it" rather than "them")?

It may help if you post a description of the tables here. For example, from the MySQL command line (not in PHP):

mysql> SHOW CREATE TABLE people;
+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table  | Create Table                                                                                                                                                                                               |
+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| people | CREATE TABLE `people` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(25) DEFAULT NULL,
  `dob` date DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 | 
+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

When you say you can't INSERT data in your parent table, could you show us an example of the code you are using to attempt that and quote the error message, if any, that results when you run it?

oh thanks for the replies! i've already fix it by the way. i just made them both innoDB. thank u both! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.