Dear all
I'm teaching mysql and php , i 'm creating simple database for bookstore whatever i created file booksite.php(script) , script is :
<?php
//connect to MySQL; note we've used our own parameters- you should use
//your own for hostname, user, and password
$connect = mysql_connect("localhost", "root", "root") or
die ("Hey loser, check your server connection.");
//create the main database if it doesn't already exist
$create = mysql_query("CREATE DATABASE IF NOT EXISTS books")
or die(mysql_error());
//make sure our recently created database is the active one
mysql_select_db("books");
//create "title" table
$title = "DROP TABLE IF EXISTS title;CREATE TABLE title (
title_id int(20) NOT NULL auto_increment,
title_name varchar(255)NOT NULL,
title_serial tinyint(2)NOT NULL default 0,
title_edition int(4) NOT NULL default 0,
PRIMARY KEY (title_id),
KEY title_serial (title_serial,title_edition)
))";
$results = mysql_query($title)
or die (mysql_error());
//create "serialname" table
$serialname = "CREATE TABLE serialname (
serialname_id int(11) NOT NULL auto_increment,
serialname_subtitle varchar(100) NOT NULL,
PRIMARY KEY (serialname_id)
))";
$results = mysql_query($serialname)
or die(mysql_error());
//create "instructors" table
$instructors = "CREATE TABLE people (
instructors_id int(11) NOT NULL auto_increment,
instructors_fullname varchar(255) NOT NULL,
instructors_serial tinyint(1) NOT NULL default 0,
PRIMARY KEY (instractors_id)
))";
$results = mysql_query($instructors)
or die(mysql_error());
echo "book Database successfully created!";
?>
but when i run the site : the message error 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 'CREATE TABLE title( title_id int(20) NOT NULL auto_increment, title_name var' at line 1
Pls anyone y can help me
I'm teaching mysql and php , i 'm creating simple database for bookstore whatever i created file booksite.php(script) , script is :
<?php
//connect to MySQL; note we've used our own parameters- you should use
//your own for hostname, user, and password
$connect = mysql_connect("localhost", "root", "root") or
die ("Hey loser, check your server connection.");
//create the main database if it doesn't already exist
$create = mysql_query("CREATE DATABASE IF NOT EXISTS books")
or die(mysql_error());
//make sure our recently created database is the active one
mysql_select_db("books");
//create "title" table
$title = "DROP TABLE IF EXISTS title;CREATE TABLE title (
title_id int(20) NOT NULL auto_increment,
title_name varchar(255)NOT NULL,
title_serial tinyint(2)NOT NULL default 0,
title_edition int(4) NOT NULL default 0,
PRIMARY KEY (title_id),
KEY title_serial (title_serial,title_edition)
))";
$results = mysql_query($title)
or die (mysql_error());
//create "serialname" table
$serialname = "CREATE TABLE serialname (
serialname_id int(11) NOT NULL auto_increment,
serialname_subtitle varchar(100) NOT NULL,
PRIMARY KEY (serialname_id)
))";
$results = mysql_query($serialname)
or die(mysql_error());
//create "instructors" table
$instructors = "CREATE TABLE people (
instructors_id int(11) NOT NULL auto_increment,
instructors_fullname varchar(255) NOT NULL,
instructors_serial tinyint(1) NOT NULL default 0,
PRIMARY KEY (instractors_id)
))";
$results = mysql_query($instructors)
or die(mysql_error());
echo "book Database successfully created!";
?>
but when i run the site : the message error 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 'CREATE TABLE title( title_id int(20) NOT NULL auto_increment, title_name var' at line 1
Pls anyone y can help me