gpt4 book ai didi

php - INSERT INTO in php 和 SQL 语法错误

转载 作者:太空宇宙 更新时间:2023-11-03 11:56:18 25 4
gpt4 key购买 nike

<分区>

我自学了 mySQL 和 php 几天,现在我陷入了这个错误,无法帮助自己。能不能看看代码,谢谢!

这是错误

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 ')' at line 7

这是页面

switch($_GET['action']) {
case 'add':
switch($_GET['type']) {
case 'movie':
$query = 'INSERT INTO
movie
(movie_name, movie_year, movie_type)
VALUES
("' . $_POST['movie_name'] . '",
' . $_POST['movie_year'] . ',
' . $_POST['movie_type'] . ')';

break;
}
break;
}
if (isset($query)) {
$result = mysql_query($query, $db) or die(mysql_error($db));
}

我认为问题可能出在这里

 <td><select name='movie_type'> 
<?php

$query = 'SELECT movietype_label FROM movietype ORDER BY movietype_id';
$result = mysql_query($query, $db) or die (mysql_error($db));


while ($row = mysql_fetch_assoc($result)) {
foreach ($row as $value) {
echo '<option value="' . $row['movietype_id'] . '">';
echo $row['movietype_label'] . '</option>';

}
}

?>
</select></td>

这里是 print_r

Array(
[movie_name] => asd
[movie_type] =>
[movie_year] => 2015
[submit] => ADD)

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com