0

所以首先我试图用这个 PHP 脚本填充一个数据库。我收到的错误是-“您的 SQL 语法有错误;请查看与您的 MySQL 服务器版本相对应的手册,以便在第 1 行的 '' 附近使用正确的语法”我明白错误是什么,我只是看不到找到它。

<?php
include("server_connect.php");
//select the db
mysql_select_db("moviedatabase");
//populate titles
$insert = "INSERT INTO tblMovieTitle (movie_id, movie_title, movie_genre, movie_rating, movie_actor_fname, movie_actor_lname) " .
"VALUES (1, 'Inglorious Basterds', 'War', 8, 'Brad', 'Pitt'), " .
"(2, 'Zombieland', 'Comedy', 8, 'Jesse', 'Eisenberg'), " .
"(3, 'Cowboys and Aliens', 'Action', 6, 'Olivia', 'Wilde'), " .
"(4, 'Contagion', 'Drama', 7, 'Matt', 'Damon')";
$results = mysql_query($insert) or die (mysql_error());
//populate genre
$genre = "INSERT INTO tblMovieGenre (movie_genre_ID, movie_genre) " .
"VALUES (100, 'Action'), " .
"(101, 'Horror'), " .
"(102, 'Comedy'), " .
"(103, 'War'), " .
"(104, 'Drama'), " .
"(105, 'Kids'), " .
"(106, 'Sci-Fi'), " .
"(107, 'Action'), " ;
$results = mysql_query($genre) or die (mysql_error());
//populate movie rating
$rating = "INSERT INTO tblMovieRating (movie_rating_ID, movie_rating ) " .
"VALUES (1001, 1), " .
"(1002, 2), " .
"(1003, 3), " .
"(1004, 4), " .
"(1005, 5), " .
"(1006, 6), " .
"(1007, 7), " .
"(1008, 8), " .
"(1009, 9), " .
"(1010, 10)";
$results = mysql_query($rating) or die (mysql_error());
//check if database is populated
echo "Database populated";
?>

是的,所以我真的无法弄清楚错误来自哪里,有人吗?预先感谢您的帮助。

4

1 回答 1

1

"(107, 'Action'), " ;

你不需要额外的逗号,

于 2013-07-14T23:41:54.903 回答