-1

I'm having issues getting to my form because of the parse error on line 20 can anyone help me out here? Because I'm trying to get to my form to test it whether it connects to my data base and can insert the data I put into it.

<?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>
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
Brett Muldrow
  • 11
  • 1
  • 6
  • replace `var db` with `$db`. – Jyothi Babu Araja Nov 19 '16 at 18:48
  • from `var db = Database.Open` it is not php syntax, so please find a php answer to copy paste from :) – cske Nov 19 '16 at 18:49
  • and a repost of your other question http://stackoverflow.com/questions/40664058/how-do-i-fix-this-parse-error-syntax-error-unexpected-con-t-variabl – Funk Forty Niner Nov 19 '16 at 18:49
  • gotta love it when they think that they can just put in any kind of code/syntax as if it were like making vegetable soup; well it isn't. – Funk Forty Niner Nov 19 '16 at 18:49
  • @JyothiBabuAraja and after that replace `.` with `->` and so on – cske Nov 19 '16 at 18:49
  • Good to have something that looks like JS mixed with PHP, isn't it? – junkfoodjunkie Nov 19 '16 at 18:50
  • @junkfoodjunkie probably node.js, just a time waster – cske Nov 19 '16 at 18:52
  • Not really a time-waster, but mixing the two leads to problems :D Node.js has some very nice speed-benefits, which, if used correctly, can help in many ways. Although latest version of Apache have taken back quite a bit of the lagging behind, methinks - haven't tested Node.js for at least a couple years. – junkfoodjunkie Nov 19 '16 at 18:54
  • Then can someone tell me how to fix this problem: Undefined index: songtitle in C:\wamp64\www\Music Input Form.php on line 7: $songtitle = $_POST["songtitle"]; – Brett Muldrow Nov 19 '16 at 19:08

1 Answers1

1

Eh... where in the world does var come from? Variables in PHP is assigned with $- fix that, use $db and $insertcommand and it will probably work. Granted, I have no idea what DB-library you're using - it doesn't look completely right, but as I said, I dunno how it works.

junkfoodjunkie
  • 3,168
  • 1
  • 19
  • 33