使用PHP将SET元素插入mysql db表

Let just say I have table in my mysql db called Film. It has a film_id which is id column and special_features column which is of type SET. Never used SET type before. Special_features column is of type set('Trailers', 'Commentaries', 'behind'),

I want to enter this row in the table:

SET("trailers", "commentaires", "behind the scenes");

How should my basic sql command look like in php? I am using MySQLi and I want basic sql string.

$sql = "INSERT INTO (special_features) VALUES (('trailers', 'commentaires', 'behind the scenes'))";

how would my sql string look like if I want only trailers and commentaries inserted?

This is just example, not sure if it is correct?

I suppose it will be something like this:

$sql = "INSERT INTO set_field(special_features) VALUES('trailers,commentaires')";

Here is another example with all Film table columns:

INSERT INTO `film`(`title`, `description`, `release_year`, `language_id`, `original_language_id`, `rental_duration`, `rental_rate`, `length`, `replacement_cost`, `rating`, `special_features`) VALUES ('blade','cutting vampires','1998',1,1,0.4,4.99,120,60,0.8, ('Trailers,Commentaries,Deleted Scenes,Behind the Scenes'))

However you must be careful with the values separated by comma. There shouldn't be a whitespace between and all values must be exact match(all characters upper and lower case) as when the table was created.

Use this to insert the data into mysql $sql = "INSERT INTO special_features (row1,row2,row3) VALUES ('trailers', 'commentaires', 'behind the scenes')";

If I'm not mistaken, you want to add values to your database, however you need to insert the same number of parameters. Right now your query is looking for 1 parameter to store in special_futures column but you are passing 3 values.

Something like this would be more appropriate.

$sql = "INSERT INTO (trailers, commentaires, behindthescenes) VALUES ("$trailers",     "$commentaires", "$behind the scenes")";