MySQL fatal error problems

Discussion in 'MySQL' started by derek34, Dec 1, 2007.

  1. #1
    Hi I'm trying to write the contents of a form to a MySQL database but when the PHP script tries to write to the table and error comes up:
    Here's the code I have:
    <?php
    $cid = mysql_connect('host', 'username', 'password')or die(mysql_error());
    
     
     mysql_select_db('lanreg', $cid) or die(mysql_error());
    
    
     $q = "CREATE TABLE IF NOT EXISTS lanreg(
    	id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
    	screenname VARCHAR(9),
    	firstname VARCHAR(32) NOT NULL,
    	lastname VARCHAR(32) NOT NULL,
    	age INT(2) NOT NULL,
    	school VARCHAR(64) NOT NULL,
    	email VARCHAR(64) NOT NULL
    	phone INT(64) NOT NULL,
    	city VARCHAR(64) NOT NULL,
    	renting VARCHAR(64) NOT NULL,
    	pizza CHAR(25) NOT NULL,
    	games VARCHAR(64),
    	movies VARCHAR(64),
    	tournaments VARCHAR(64),
    	comments VARCHAR(64)
     
     );";
    
     mysql_query($q) or die(mysql_error());
    
    
    
    
     $q = "INSERT INTO lanreg (
    	id,
    	screenname,
    	firstname,
    	lastname,
    	age,
    	school,
    	email,
    	phone,
    	city,
    	renting, 
    	pizza,
    	games,
    	movies,
    	tournaments,
    	comments
    	) VALUES(
    	'$_POST[screen]',
    	'$_POST[first]',
    	'$_POST[last]',
    	'$_POST[age]',
    	'$_POST[email]',
    	'$_POST[phone]',
    	'$_POST[city]',
    	'$_POST[rent]',
    	'$_POST[pizza]',
    	'$_POST[games]',
    	'$_POST[movies]',
    	'$_POST[tourn]',
    	'$_POST[comments]'
    	);";
     
     mysql_query($q) or die(mysql_error());
     mysql_close($cid);
    }
    ?>
    PHP:
    It connects fine, but there are just some errors.
    Any idea why?
    Any help is greatly appreciated.
    Thanks
    - Derek
     
    derek34, Dec 1, 2007 IP
  2. Petey

    Petey Peon

    Messages:
    68
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You are missing a comma at the end of "email VARCHAR(64) NOT NULL"
     
    Petey, Dec 2, 2007 IP