我和绿色一样绿。我正在尝试为我的DVD构建一个数据库。现在我正在尝试构建一个表单来输入数据。我使用Dreamweaver进行编码,它告诉我在' VALUE'上有语法错误。线。当我运行代码时,我得到上述错误。但唯一的&#39 ;;'在最后一行。我确定这是一个愚蠢的事情我做错了但我无法在你的任何其他问题或调试页面找到答案。提前谢谢,请温柔......我是新人!
// Write data to table.
$sql=("INSERT INTO movies (Movies, Rating, Genre, Year, Actors, Time, Notes, Viewed, BitRate, link)
VALUES ('$_POST[Movies]','$_POST[Rating]','$_POST[Genre]','$_POST[Year]','$_POST[Actors]','$_POST[Time]','$_POST[Notes]','$_POST[Viewed]','$_POST[BitRate]','$_POST[link]')";
if (!mysqli_query($con,$sql))
{
die('Error: X ' . mysql_error($con));
}
echo "1 record added";
mysqli_close($con);
答案 0 :(得分:1)
小心有一个额外的开口括号:
$sql=("...
应该是
$sql="...
答案 1 :(得分:1)
使用此修改您的查询并使用:
$sql="INSERT INTO movies (Movies, Rating, Genre, Year, Actors, Time, Notes, Viewed, BitRate, link) VALUES ("'.$_POST[Movies].'","'.$_POST[Rating].'","'.$_POST[Genre].'","'.$_POST[Year].'","'.$_POST[Actors].'","'.$_POST[Time].'","'.$_POST[Notes].'","'.$_POST[Viewed].'","'.$_POST[BitRate].'","'.$_POST[link].'")";
if (!mysqli_query($con,$sql)) { die('Error: X ' . mysql_error($con)); }
echo "1 record added";
mysqli_close($con);
答案 2 :(得分:0)
在任何不应该出现的地方之前你有一个(
。
$sql=("INSERT INTO movi...
^ // What's this?
你应该:
$sql="INSERT INTO movies (Movies, Rating, Genre, Year, Actors, Time, Notes, Viewed, BitRate, link)
VALUES ('$_POST[Movies]','$_POST[Rating]','$_POST[Genre]','$_POST[Year]','$_POST[Actors]','$_POST[Time]','$_POST[Notes]','$_POST[Viewed]','$_POST[BitRate]','$_POST[link]')";
Alo,只是FYI,通常当你收到;
错误时,就意味着上面一行出了问题。
答案 3 :(得分:0)
用此
替换您的查询$sql="INSERT INTO movies (Movies, Rating, Genre, Year, Actors, Time, Notes, Viewed, BitRate, link)
VALUES ('".$_POST['Movies']."','".$_POST['Rating']."','".$_POST['Genre']."','".$_POST['Year']."','".$_POST['Actors']."','".$_POST['Time']."','".$_POST['Notes']."','".$_POST['Viewed']."','".$_POST['BitRate']."','".$_POST['link']."')";