-2
$sql = 'INSERT INTO `a1343640_test`.`Orders`
 (`TicketId`, `Id`, `MenuItemName`, `Price`, `Quantity`, `Student ID`, `Student Year`, `Student Name`, `Student Email`)
  VALUES ('$ticketID', '$orderID ', '$menu', '$price', '$quantity', '$studID', '$StudYr', '$StudName', '$StudEmail');';

Is what I have, however I’ve got a problem with the values which I am unsure what I have done wrong. If someone can assist me that would be great.

Insane Skull
  • 9,220
  • 9
  • 44
  • 63
  • You forgot the `.` Ex: `'.$ticketID.', '.$orderID.'` – aldrin27 Apr 22 '16 at 06:37
  • 1
    See how to concatenate strings: http://stackoverflow.com/q/8336858/3933332 But remember that you should enclose your strings in quotes for the query. – Rizier123 Apr 22 '16 at 06:38
  • $sql = "INSERT INTO `a1343640_test`.`Orders` (`TicketId`, `Id`, `MenuItemName`, `Price`, `Quantity`, `Student ID`, `Student Year`, `Student Name`, `Student Email`) VALUES ('$ticketID', '$orderID ', '$menu', '$price', '$quantity', '$studID', '$StudYr', '$StudName', '$StudEmail')"; – RJParikh Apr 22 '16 at 06:40
  • $StudName contains string so in your case query gives error without quotes. @Anant – RJParikh Apr 22 '16 at 06:45

2 Answers2

0

Update your query:

$sql = 'INSERT INTO `a1343640_test`.`Orders`
 (`TicketId`, `Id`, `MenuItemName`, `Price`, `Quantity`, `Student ID`, `Student Year`, `Student Name`, `Student Email`)
  VALUES ("'.$ticketID.'", "'.$orderID.'", "'.$menu.'", "'.$price.'", "'.$quantity.'", "'.$studID.'", "'.$StudYr.'", "'.$StudName.'", "'.$StudEmail.'");';
Dipanwita Kundu
  • 1,637
  • 1
  • 9
  • 14
0

You are using quotes in wrong way, try this

$sql = 'INSERT INTO `a1343640_test`.`Orders`
 (`TicketId`, `Id`, `MenuItemName`, `Price`, `Quantity`, `Student ID`, `Student Year`, `Student Name`, `Student Email`)
  VALUES ("'.$ticketID.'", "'.$orderID.'", "'.$menu.'", "'.$price.'", "'.$quantity.'", "'.$studID.'", "'.$StudYr.'", "'.$StudName.'", "'.$StudEmail.'");';

or another way is

$sql = "INSERT INTO a1343640_test.Orders (TicketId, Id, MenuItemName, Price, Quantity, Student ID, Student Year, Student Name, Student Email) VALUES ('$ticketID', '$orderID ', '$menu', '$price', '$quantity', '$studID', '$StudYr', '$StudName', '$StudEmail')";
Ankur Tiwari
  • 2,762
  • 2
  • 23
  • 40