PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, February 1, 2022

[FIXED] phpmyadmin error: cant create table error number 150

 February 01, 2022     mysql, php, phpmyadmin     No comments   

Issue

I tried to create the following table:

CREATE TABLE `updates` (
`update_id` INT(11) AUTO_INCREMENT ,
`update` VARCHAR(45),
`user_id_fk` VARCHAR(45),
`created` INT(11) ,
`ip` VARCHAR(45),
PRIMARY KEY (`update_id`),
FOREIGN KEY (user_id_fk) REFERENCES users(user_id));

Phpmyadmin shown error as

#1005 - Can't create table 'friends.updates' (errno: 150) (Details...)

When I click on 'Details' I get:

InnoDB Documentation Supports transactions, row-level locking, and foreign keys [ Variables | Buffer Pool | InnoDB Status ]

Please help me to overcome with this error.


Solution

It seems user_id field data type in users table is int while here you are creating relation with varchar(45).

For foreign keys data type should be same, so keep it as was in users table.



Answered By - Zafar Malik
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing