Jump to content

mySQL and PHP syntax error


killjoi

Recommended Posts

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]

Link to comment
https://forums.phpfreaks.com/topic/1359-mysql-and-php-syntax-error/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.