Why does my PHP code not work?

pandemonium7386

New member
In the end, I get an error that says Can't create table './test/employeeTbl.frm' (errno: 150)

<?php
include("dbLogin.php");

$query="CREATE TABLE employeeTbl(
employeeID int(6) NOT NULL primary key auto_increment,
emFirstName varchar(30) NOT NULL,
emAddress varchar(50) NOT NULL,
emCity varchar(30) NOT NULL,
emState varchar(10) NOT NULL,
emZip int(5) NOT NULL,
emPermID varchar(10) NOT NULL,
emNotes text NOT NULL,
emPix varchar(100) NOT NULL,
INDEX(emPermID),
FOREIGN KEY (emPermID) REFERENCES permissionTbl(permissionID)
on update cascade
on delete cascade
)type=InnoDB";

if(!($dbLink = mysql_connect("localhost",$username,$password)))
{
print("Failed to connect to $database<br>\n");
exit();
}

if(!($dbResult = mysql_query("USE $database", $dbLink)))
{print("Can't use the database.<br>\n");
exit();
}

mysql_query($query) or die(mysql_error());
?>
 
You shouldn't be dynamically creating tables anyway. sit down and design your database schema carefully and create the tables in a database management tool. Use php to dynamically insert/modify records.
 
try modify
employeeID int(6) NOT NULL primary key auto_increment,
to
employeeID int(6) NOT NULL auto_increment,
PRIMARY KEY(employeeID),
 
Back
Top