joeysarsenal Posted September 15, 2007 Share Posted September 15, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/69446-solved-mysql-with-php-table-creating/ Share on other sites More sharing options...
leafface Posted September 15, 2007 Share Posted September 15, 2007 The outer () is not closed at the end ... Staff_ID varchar(20)); Quote Link to comment https://forums.phpfreaks.com/topic/69446-solved-mysql-with-php-table-creating/#findComment-348960 Share on other sites More sharing options...
joeysarsenal Posted September 15, 2007 Author Share Posted September 15, 2007 ahh i knew it was something simple. Thank you for your help. Quote Link to comment https://forums.phpfreaks.com/topic/69446-solved-mysql-with-php-table-creating/#findComment-349057 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.