解析错误:语法错误,意外'var'(T_VAR),期望在第20行的C:\ wamp64 \ www \ Music输入Form.php中的文件结束

时间:2016-11-19 18:45:50

标签: php html parsing

我遇到问题因为第20行的解析错误可以帮助我在这里找到我的表单吗?因为我试图访问我的表单来测试它是否连接到我的数据库并且可以插入我放入其中的数据。

<?php
$server = "localhost";
$database = "music database";
$user = "root";
$pass = "root";

$songtitle = $_POST["songtitle"];
$songartist = $_POST["songartist"];
$songalbum  = $_POST["songalbum"];
$yearreleased = $_POST["yearreleased"];
$monthplayed = $_POST["month_played"];
$dayplayed = $_POST["dayplayed"];
$dateplayed = $_POST["dateplayed"];
$timeplayed = $_POST["timeplayed"];

$connection = mysqli_connect($server, $user, $pass, $database);



var db = Database.Open("music database");
var insertCommand = "INSERT INTO `month 1` (`Song Title`, `Song Artist`, `Song Album`, `Year Released`, `Month Played`, `Day of the Week Played`, `Date Played`, `Time Played`) VALUES ($songtitle, $songartist, $songalbum, $yearreleased, $monthplayed, $dayplayed $dateplayed, $timeplayed)";
db.Execute(insertCommand, songtitle, songartist, songalbum, yearreleased, monthplayed, dayplayed, dateplayed, timeplayed);
Response.Redirect("~/music database");

?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Music Input Form</title>
</head>
<body>


<header><h1><center>Music Data</center></h1></header>
<form method="post" action="insert.php">
<fieldset>
<center>Song Title:             <input type = "text" name = "songtitle" id = "songtitle"><br><br></center>
<center>Song Artist:            <input type = "text" name = "songartist" id = "songartist"><br><br></center>
<center>Song Album:             <input type = "text" name = "songalbum" id = "songalbum"><br><br></center>
<center>Year Released:          <input type = "year" name = "yearreleased" id = "yearreleased"><br><br></center>
<center>Month Played:           <input type = "text" name = "monthplayed" id = "monthplayed"><br><br></center>
<center>Day of the Week Played: <input type = "text" name = "dayplayed" id = "dayplayed"><br><br></center>
<center>Date Played:            <input type = "date" name = "dateplayed" id = "dateplayed"><br><br></center>
<center>Time Played:            <input type = "time" name = "timeplayed" id = "timeplayed"><br><br></center>
<center><input type = "submit" value = "Add Song"><input type = "reset"  value = "Clear"></center>
</fieldset>
</form>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

呃...... var来自世界的哪个地方? PHP中的变量已分配$ - 修复它,使用$db$insertcommand,它可能会起作用。当然,我不知道你正在使用什么数据库 - 它看起来并不完全正确,但正如我所说,我不知道它是如何工作的。