surfer surfer - 6 months ago 21
SQL Question

MySQL INSERT query does not update the DB

attent table :

id int(11) primary key

userID int (11) forigen key from users table

date date

start_time text

end_time text

approv enum default 0

my query :

$sql = "INSERT INTO attent ".
"(id,userID,date,start_time,end_time,approv) ".
"VALUES ".
"('NULL','$userid','$date','$start_time','$end_time','NULL')";

$query = mysqli_query($db,$sql);


I got config.php file that help communicate with dB. I did a few insert queries before and all of them work just fine. I can not understand where is my mistake.

Answer

Write your query as below:-

"INSERT INTO attent(`id`,`userID`,`date`,`start_time`,`end_time`,`approv`)
VALUES(NULL,'$userid','$date','$start_time','$end_time',NULL)"