SQLSTATE [42000] 我的插入查询语法中的错误
SQLSTATE[42000] error in my Insert Query syntax
诚然,我已经有一段时间没有触及 MYSQL 所以如果这是一个简单的错误,请原谅我。我正在尝试使用 PDO 查询插入数据,但出现此错误
Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[42000]: Syntax error or access violation: 1064 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 ') VALUES ( '',
'/dYtAyg4vD88hIfrR1VKDnVGhnE6.jpg', '106646', 'The'
这是我的查询
$query = $db->prepare("INSERT INTO `cache_movies` (
api_adult,
api_backdrop_path,
api_id,
api_original_title,
api_release_date,
api_poster_path,
api_popularity,
api_title,
api_video,
api_vote_average,
api_vote_count,
) VALUES (
:api_adult,
:api_backdrop_path,
:api_id,
:api_original_title,
:api_release_date,
:api_poster_path,
:api_popularity,
:api_title,
:api_video,
:api_vote_average,
:api_vote_count,
)");
$query->execute(array(
':api_adult' => $results['results'][0]['adult'],
':api_backdrop_path' => $results['results'][0]['backdrop_path'],
':api_id' => $results['results'][0]['id'],
':api_original_title' => $results['results'][0]['original_title'],
':api_release_date' => $results['results'][0]['release_date'],
':api_poster_path' => $results['results'][0]['poster_path'],
':api_popularity' => $results['results'][0]['popularity'],
':api_title' => $results['results'][0]['title'],
':api_video' => $results['results'][0]['video'],
':api_vote_average' => $results['results'][0]['vote_average'],
':api_vote_count' => $results['results'][0]['vote_count']
));
我使用了在线 SQL 验证器,它说错误在 ) VALUES (
所在的行?
删除这些行末尾的逗号:
api_vote_count,
和
:api_vote_count,
您必须删除这些逗号:
诚然,我已经有一段时间没有触及 MYSQL 所以如果这是一个简单的错误,请原谅我。我正在尝试使用 PDO 查询插入数据,但出现此错误
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 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 ') VALUES ( '', '/dYtAyg4vD88hIfrR1VKDnVGhnE6.jpg', '106646', 'The'
这是我的查询
$query = $db->prepare("INSERT INTO `cache_movies` (
api_adult,
api_backdrop_path,
api_id,
api_original_title,
api_release_date,
api_poster_path,
api_popularity,
api_title,
api_video,
api_vote_average,
api_vote_count,
) VALUES (
:api_adult,
:api_backdrop_path,
:api_id,
:api_original_title,
:api_release_date,
:api_poster_path,
:api_popularity,
:api_title,
:api_video,
:api_vote_average,
:api_vote_count,
)");
$query->execute(array(
':api_adult' => $results['results'][0]['adult'],
':api_backdrop_path' => $results['results'][0]['backdrop_path'],
':api_id' => $results['results'][0]['id'],
':api_original_title' => $results['results'][0]['original_title'],
':api_release_date' => $results['results'][0]['release_date'],
':api_poster_path' => $results['results'][0]['poster_path'],
':api_popularity' => $results['results'][0]['popularity'],
':api_title' => $results['results'][0]['title'],
':api_video' => $results['results'][0]['video'],
':api_vote_average' => $results['results'][0]['vote_average'],
':api_vote_count' => $results['results'][0]['vote_count']
));
我使用了在线 SQL 验证器,它说错误在 ) VALUES (
所在的行?
删除这些行末尾的逗号:
api_vote_count,
和
:api_vote_count,
您必须删除这些逗号: