Jump to content

[SOLVED] Mysql With PHp "Table Creating"


joeysarsenal

Recommended Posts

Im trying to create a database. Which has been created and i have many tables within the database but when i go to create my "Supplies" Table i get this error.

Coding is below

 

<?php

 

$host = "localhost";

$user = "root";

$pass = "";

 

 

 

$Connect = @mysql_connect($host, $user, $pass);

 

if(!$Connect){

  echo('<p>Unable to connect to the' .

      ' database server at this time.</p>');

  exit();

}

 

 

mysql_select_db("Cool");

 

 

    $sql = "CREATE TABLE Services(" .

  "Service_ID int(4) NOT NULL AUTO_INCREMENT PRIMARY KEY," .

  "Service_Name varchar(100) NOT NULL," .

  "Service_Type varchar(50) NOT NULL," .

  "Service_Cost varchar(20) ," .

  "Service_Requirement varchar(20),".

  "Staff_ID varchar(20);";

 

 

echo "SQL is " . $sql . "<br />";

 

if(mysql_query($sql)){

  echo("<p>Services table successfully created!</p>");

}

else{

  print("<p>Error creating Services table: " . mysql_error() . "</p>");

}

?>

 

I get this error

SQL is CREATE TABLE Supplys(Supply_ID int(4) NOT NULL AUTO_INCREMENT PRIMARY KEY,Supply_Name varchar(100) NOT NULL,Supply_Type varchar(50) NOT NULL,Supply_Cost varchar(20) ,Supply_Availble varchar(20),Staff_ID varchar(20);

 

Error creating Supplys table: 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 1

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.