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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.