joeysarsenal Posted October 16, 2007 Share Posted October 16, 2007 I seem to be getting this error. When trying to create a table and cant seem to find were i went wrong. Code im using is <?php /* create the Staff Table */ $host = "localhost"; $user = "root"; $pass = ""; // include( "../some/wierd/folder/details.inc" ); $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("plaincart"); $sql = "CREATE TABLE clients(" . "member_id int(4) NOT NULL AUTO_INCREMENT PRIMARY KEY," . "firsname varchar(100) NOT NULL," . "lastname varchar(100) NOT NULL," . "email varchar(100) NOT NULL ," . "city varchar(100) NOT NULL,". "address varchar(100) NOT NULL," . "postcode varchar(4) ," . "login varchar(100) NOT NULL default,". "passwd varchar(32) NOT NULL );"; echo "SQL is " . $sql . "<br />"; if(mysql_query($sql)){ echo("<p>client table successfully created!</p>"); } else{ print("<p>Error creating clients table: " . mysql_error() . "</p>"); } ?> Error creating client 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 'passwd varchar(32) NOT NULL )' at line 1 Quote Link to comment Share on other sites More sharing options...
trq Posted October 16, 2007 Share Posted October 16, 2007 You dont state any default value for login. Either remove the default keyword, or define a default. "CREATE TABLE clients(" . "member_id int(4) NOT NULL AUTO_INCREMENT PRIMARY KEY," . "firsname varchar(100) NOT NULL," . "lastname varchar(100) NOT NULL," . "email varchar(100) NOT NULL ," . "city varchar(100) NOT NULL,". "address varchar(100) NOT NULL," . "postcode varchar(4) ," . "login varchar(100) NOT NULL default 'foo',". "passwd varchar(32) NOT NULL );"; Quote Link to comment Share on other sites More sharing options...
joeysarsenal Posted October 16, 2007 Author Share Posted October 16, 2007 ty very much quick reply Quote Link to comment 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.