Hi, I am looking to create 3 tables for a project I am just starting on, and was wondering if anyone could help spot the error(s) in my code:
I am trying to run it through a php file. The server/login details are in the include file, which are correct because ive used the same file to create other parts of the database. This is the error I keep getting:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'KEY (employer_id) ) ENGINE=MyISAM' at line 11
<?php
include 'db.inc.php';
$db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or
die('Unable to connect');
mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db));
//create customers table
$query = 'CREATE TABLE IF NOT EXISTS customer (
people_id INTEGER NOT NULL AUTO_INCREMENT,
first_name VARCHAR(20) NOT NULL,
last_name VARCHAR(20) NOT NULL,
email VARCHAR(50) NOT NULL,
address_1 VARCHAR(30) NOT NULL,
address_2 VARCHAR(30),
county VARCHAR(30) NOT NULL,
postcode VARCHAR(10) NOT NULL,
telephone VARCHAR(15),
customer_attribute VARCHAR(255) NOT NULL,
active BOOLEAN NOT NULL DEFAULT TRUE,
PRIMARY KEY(people_id)
)
ENGINE=MyISAM';
mysql_query($query, $db) or die(mysql_error($db));
//create employer table
$query = 'CREATE TABLE IF NOT EXISTS employer (
employer_id INTEGER NOT NULL AUTO_INCREMENT,
name VARCHAR(50) NOT NULL,
address_1 VARCHAR(30) NOT NULL,
address_2 VARCHAR(30),
county VARCHAR(30) NOT NULL,
postcode VARCHAR(10) NOT NULL,
email VARCHAR(50) NOT NULL,
telephone VARCHAR(15) NOT NULL,
active BOOLEAN NOT NULL DEFAULT TRUE,
PRIMATY KEY (employer_id)
)
ENGINE=MyISAM';
mysql_query($query, $db) or die(mysql_error($db));
//create advert table
$query = 'CREATE TABLE IF NOT EXISTS advert (
advert_id INTEGER NOT NULL AUTO_INCREMENT,
employer_id INTEGER NOT NULL,
start_date DATE NOT NULL,
finish_date DATE NOT NULL,
vacancies TINYINT UNSIGNED,
description TEXT[3000] NOT NULL,
app_deadline DATE,
location VARCHAR(30) NOT NULL,
salary MEDIUMINT(6) UNSIGNED NOT NULL,
web_link VARCHAR(50),
app_process VARCHAR(255) NOT NULL,
attributes VARCHAR(255) NOT NULL,
PRIMARY KEY (advert_id)
FOREIGN KEY (employer_id) REFERENCES employer(employer_id)
)
ENGINE=MyISAM';
mysql_query($query, $db) or die(mysql_error($db));
echo 'success!';
?>
Thanks!