MySQL Forums
Forum List  »  MySQL Administrator

Mysql Error
Posted by: abdoo saad
Date: February 08, 2010 04:58AM

Dear all
I'm teaching mysql and php , i 'm creating simple database for bookstore whatever i created file booksite.php(script) , script is :
//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

//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 : http://localhost/booksite.php 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

Options: ReplyQuote

Written By
Mysql Error
February 08, 2010 04:58AM
February 19, 2010 06:26PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.