0

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.!

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by jjemphoung
0

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)
0

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?

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.