Skip to Content

Script Error

Dear all, I'm getting this error message from my script

 <?php
  //connect to MySQL;
//your own for hostname, user, and passwordd
 $connect = mysql_connect("localhost", "root", "root1") or
     die ("Hey loser, check your server connection.");

$create=mysql_query("CREATE DATABASE IF NOT EXISTS english_books")
or die (mysql_error);
mysql_select_db("english_books")
//craate table instructors
$instructors = "CREATE TABLE instructors (
   Instructor_id varchar(4) NOT NULL default 0,
   Instructor_name varchar(250) NOT NULL,
  PRIMARY KEY  (Instructor_id)
  KEY Instructor_name (Instructor_name,Instructor_id)
 )";
 $results = mysql_query($instructors)
  or die (mysql_error());
 
 //create table isbn
   $isbn="CREATE TABLE isbn (
   ISBN varchar(250) NOT NULL,
  PRIMARY KEY  (ISBN)
  )";
  $results = mysql_query($isbn)
  or die(mysql_error());

//crate table title
$title= "CREATE TABLE title(
  Title_id` int(4) NOT NULL auto_increment,
  Title` varchar(255) NOT NULL default '0',
  Sub_title` varchar(255) NOT NULL default '0',
  Author` varchar(255) NOT NULL default '0',
  Serial_number` int(6) NOT NULL default '0',
  Year` int(4) NOT NULL default '0',
  Edition` varchar(250) NOT NULL default '0',
  PRIMARY KEY  (`Title_id`)
)";
 $results = mysql_query($title)
  or die(mysql_error());
echo "english books  Database successfully created!";
 ?>

?>
Pronco's picture

Investigate step by step.

Have you set up your mySQL username and password correctly?

Would you please try to check them whether they are working or not via your mysql client. Assuming running the following would give you the proper answer:

Re-Script error

Thank y for interested to me, i have checked my username and password but the new message is : 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 ')' at line 6

<?php //connect to MySQL //your own for hostname, user, and passwordd $link= mysql_connect("localhost","root","root1") or die ("Hey loser,check your server connection.");

mysql_select_db("english books"); //craate table instructors $instructors = "CREATE TABLE instructors ( Instructor_id varchar(4)NOT NULL, Instructor_name varchar(250) NOT NULL, PRIMARY KEY (Instructor_id), KEY Instructor_name (Instructor_name,Instructor_id), )"; $results = mysql_query($instructors) or die (mysql_error());

//create table isbn $isbn="CREATE TABLE isbn ( ISBN varchar(250) NOT NULL, PRIMARY KEY (ISBN) )"; $results = mysql_query($isbn) or die(mysql_error());

//crate table title $title= "CREATE TABLE title( Title_id` int(4) NOT NULL auto_increment, Title` varchar(255) NOT NULL default '0', Sub_title` varchar(255) NOT NULL default '0', Author` varchar(255) NOT NULL default '0', Serial_number` int(6) NOT NULL default '0', Year` int(4) NOT NULL default '0', Edition` varchar(250) NOT NULL default '0', PRIMARY KEY (`Title_id`) )"; $results = mysql_query($title) or die(mysql_error()); echo "english books Database successfully created!"; ?>

Pronco's picture

Likelihood.

Look into your spelling mistakes within your SQL syntax near line 6 - something like crate

Faissl's picture

this is the script, where is

also, better use mysqli_connect not mysql_connect and keep adding i's in every mysql_xxxx, it's a better habit..


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


Dr. Radut | forum