Jump to content


Photo

mySQL and PHP syntax error


  • Please log in to reply
2 replies to this topic

#1 killjoi

killjoi
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 14 November 2003 - 12:52 AM

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]

#2 MDHall

MDHall
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 14 November 2003 - 02:02 AM

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.
~~MD~~

#3 sirmanson

sirmanson
  • Members
  • PipPip
  • Member
  • 16 posts
  • LocationTucson, AZ USA

Posted 14 November 2003 - 03:48 PM

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\');




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users