I'm getting the following syntax error. I have reviewed numerous quest on SE and I can not see what I'm doing wrong.
Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order-items(ordit_sid, ordit_datetime, ordit_sku, ordit_cat, ordit_ip, ordit_qt' at line 1 in /home/q86hl0ouzddw/public_html/order.php:11 Stack trace: #0 /home/q86hl0ouzddw/public_html/order.php(11): PDOStatement->execute(Array) #1 {main} thrown in /home/q86hl0ouzddw/public_html/order.php on line 11
If I echo $sesid it displays 5b468520d5a8b-96-58-55-118 which is correct.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
include "../connect-pdo.php";
$sesid = $_POST['sesid'];
$stmt = $conn->prepare("INSERT INTO order-items(ordit_sid, ordit_datetime,
ordit_sku, ordit_cat, ordit_ip, ordit_qty) SELECT sel_sid, sel_datetime,
sel_sku, sel_cat, sel_ip, sel_qty FROM selections WHERE sel_sid = ?");
$stmt->execute([$sesid]);
?>
What could be causing the error?