Salve a tutti,
sto imparando php da un libro e da quello ho copiato la seguente query:
codice:
INSERT INTO people (people_id, people_fullname, people_isactor, people_ isdirector) VALUES (1, "Jim Carrey", 1, 0), (2, "Tom Shadyac", 0, 1), (3, "Lawrence Kasdan", 0, 1), (4, "Kevin Kline", 1, 0), (5, "Ron Livingston", 1, 0), (6, "Mike Judge", 0, 1)';
EDIT: Ecco il file PHP completo (ho eseguito la query con phpMyadmin e funziona!!)
) :
codice:
$db = mysql_connect('127.0.0.1', 'root', '');
mysql_select_db('moviesite', $db);
# $query = 'INSERT INTO movie
# (movie_id, movie_name, movie_type, movie_year, movie_leadactor, movie_director)
# VALUES
# (1, "Bruce Almighty", 5, 2003, 1, 2),
# (2, "Office Space", 5, 1999, 5, 6),
# (3, "Grand Canyon", 2, 1991, 4, 3)';
# mysql_query($query, $db) or die(mysql_error($db));
# $query = 'INSERT INTO movietype
# (movietype_id, movietype_label)
# VALUES
# (1,"Sci Fi"),
# (2, "Drama"),
# (3, "Adventure"),
# (4, "War"),
# (5, "Comedy"),
# (6, "Horror"),
# (7, "Action"),
# (8, "Kids")';
# mysql_query($query, $db) or die(mysql_error($db));
$query = 'INSERT INTO people
(people_id, people_fullname, people_isactor, people_isdirector)
VALUES
(1, "Jim Carrey", 1, 0),
(2, "Tom Shadyac", 0, 1),
(3, "Lawrence Kasdan", 0, 1),
(4, "Kevin Kline", 1, 0),
(5, "Ron Livingston", 1, 0),
(6, "Mike Judge", 0, 1)';
mysql_query($query, $db) or die(mysql_error($db));
echo 'Data inserted succefully';
Ma mi restituisce quest'errore:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'isdirector) VALUES (1, "Jim Carrey", 1, 0), ' at line 2.
Perché?
PS. ho cercato in internet, ma non ho trovato: se c'è un correttore ortografico per query Mysql. Ne conoscete uno?
GRAZIE MILLE!!