php - Error in SQL syntax DATATIME option -


i started new php script, , used first time datatime option in mysql. think makes problem.

my sql table :

id int(6) auto_increment, name varchar(40) not null, pseudo varchar(40) not null, email varchar(40) not null, password varchar(40) not null, plan varchar(40) not null, date datetime default current_timestamp, points int(6) not null, primary key(id,name,pseudo,email,password,date,points,plan) 

when try execute query:

insert users(null,"name","pseudo","email@email.com","pass1919",null, "100"); 

this error displays :

error 1064 (42000): have error in sql syntax; check manual corresponds mysql server version right syntax use near 'null, "name","pseudo","email@email.com","pass1919",null,"100")' @ line 1

as others have said, and

insert users(name,pseudo,email,password,paln,date,poits) values("name","pseudo","email@email.com","pass1919",'', null, "100"); 

plan varchar(40) not null,

what missed plan not null, , either enter null date or prefer omit completely.

insert users(name,pseudo,email,password,paln,poits) values("name","pseudo","email@email.com","pass1919",'', "100"); 

if count fields , inputs in of above responses not equal. field list optional in insert use them, readability , make sure have order , number of inputs correct.

last thing change primary key, auto increment field, if need other compound indexes, should add them separate , make unique requirements require. primary keys should surrogate key, defined way

  • the value unique system-wide, hence never reused
  • the value system generated
  • the value not manipulable user or application
  • the value contains no semantic meaning
  • the value not visible user or application
  • the value not composed of several values different domains.

the other keys should relate data, , said if need compound unique key, or unique filed email make separate primary one.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -