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
https://forums.phpfreaks.com/topic/69446-solved-mysql-with-php-table-creating/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.