1

I'm pretty new to programming with PHP 5.5 and i tried to execute this piece of code but it retrieves me the following error message:

Parse error: syntax error, unexpected 'INSERT' (T_STRING) in "servername" on line 9

My code should get the three values username, order and date, insert them into my database and output a short success message. Here is my code:

<?php
require "conn.php";
$username = $_POST["user"];
$order = $_POST["order"];
$date = date(d m Y - H:i:s,strtotime($string));
$time = $_POST[$date];


$mysql_qry = "INSERT into Orders (Username, Drinkname, Date) values ($username, $order, $date)";
$result = mysqli_query($conn, $mysql_qry);

if($result){
    echo "order successful from $username";
} else {
    echo mysql_error();
}
?>
rapidRoll
  • 300
  • 1
  • 9
Gabsii
  • 448
  • 7
  • 20
  • 2
    here it is: `$date = "date` - remove the `"` – Jeff Dec 12 '16 at 22:25
  • 1
    If you are just starting to programm, treat yourself and get an editor with syntax-highlighting. Such as sublime, notepad++. With such an editor you'll spot such mistakes very quick. – Jeff Dec 12 '16 at 22:27
  • You can see the syntax highlighting change in your question... – AbraCadaver Dec 12 '16 at 22:29
  • The [documentation](http://php.net/manual/en/langref.php) is your second best friend (after a decent editor, as @Jeff already said). The 5th line should read: [`$date = date('d m Y - H:i:s', strtotime($string));`](http://php.net/manual/en/function.date.php) – axiac Dec 12 '16 at 22:56

0 Answers0