killjoi Posted November 14, 2003 Share Posted November 14, 2003 not sure if my problem is with the php or the sql as i am relatively new to this on both sides basically it seems that there is a problem inserting more than 8 fields into my database at one time. if i cut the insert down so that it ends at type then the insert works fine. when attempting to run the entire insert i receive a syntax error message. is there some kind of size limit on queries? CREATE TABLE `users` ( `userid` INT( 25 ) NOT NULL AUTO_INCREMENT , `first_name` VARCHAR( 25 ) NOT NULL , `last_name` VARCHAR( 25 ) NOT NULL , `email_address` VARCHAR( 40 ) NOT NULL , `phone_number` VARCHAR( 25 ) NOT NULL , `password` VARCHAR( 255 ) NOT NULL , `rate` VARCHAR( 10 ) NOT NULL , `info` TEXT NOT NULL , `skills` TEXT NOT NULL , `references` TEXT NOT NULL , `type` ENUM( \'0\', \'1\', \'2\', \'3\' ) DEFAULT \'0\' NOT NULL , `signup_date` DATETIME DEFAULT \'0000-00-00 00:00:00\' NOT NULL , `last_login` DATETIME DEFAULT \'0000-00-00 00:00:00\' NOT NULL , `activated` ENUM( \'0\', \'1\' ) DEFAULT \'0\' NOT NULL , `available_date` DATE NOT NULL , `recruiter_id` VARCHAR( 25 ) NOT NULL , `company_name` VARCHAR( 40 ) NOT NULL , PRIMARY KEY ( `userid` ) ) COMMENT = \'Membership Information\'; [php:1:b97684e4dd] $insert = \"INSERT INTO users ( first_name, last_name, email_address, phone_number, password, info, signup_date, type, rate, skills, references, recruiter_id, available_date) VALUES ( \'$first_name\', \'$last_name\', \'$email_address\', \'$phone_number\', \'$db_password\', \'$info2\', now(), \'0\', \'$rate\', \'$skills2\', \'$references2\', \'$recruiter_id\', \'$available_date\')\"; $sql = mysql_query($insert) or die (mysql_error()); [/php:1:b97684e4dd] Quote Link to comment https://forums.phpfreaks.com/topic/1359-mysql-and-php-syntax-error/ Share on other sites More sharing options...
MDHall Posted November 14, 2003 Share Posted November 14, 2003 I dont think the info youre inserting is matching up to the fields of the table. In other words, theyre not in the same/correct order. For example, in your table columns you go from password to rate to info. Your insert isn\'t in the same order, going from password to info to signup date. Try inserting in the same exact order as your columns. Quote Link to comment https://forums.phpfreaks.com/topic/1359-mysql-and-php-syntax-error/#findComment-4500 Share on other sites More sharing options...
sirmanson Posted November 14, 2003 Share Posted November 14, 2003 You can also specify the Column names in a list first and use the values statement ie : insert into table (id,name) values (1,\'Me\'); Quote Link to comment https://forums.phpfreaks.com/topic/1359-mysql-and-php-syntax-error/#findComment-4523 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.