我的sql格式有什么问题

时间:2016-04-22 06:36:43

标签: php mysql

$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');';

我拥有的是什么,但是我的价值存在问题,我不确定我做错了什么。如果有人可以帮助我那会很棒。

2 个答案:

答案 0 :(得分:0)

更新您的查询:

$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.'");';

答案 1 :(得分:0)

你错误地使用引号,试试这个

$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.'");';

或其他方式

$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')";