Hi,
I'm trying to insert data from a form into a Database. I can send static information to the database, but as soon as I write "'$_POST[gname_$i]'" I get an error.
The error message is:
Parse error: syntax error, unexpected T_VARIABLE, expecting ']' in ... on line 5.
I don't understand why I keep getting this error, I have gone through it to see if I've missed anything but cannot find anything wrong.
Please could someone help, as I really don't know what is causing this error to occur?
Many Thanks.
<?php
for ($i=1; $i<=$no_of_tickets; $i++){
$dbh->exec("INSERT INTO order (tick_no, gname, menu_1, menu_2, menu_3, menu_4, tab_id)
VALUES ('$i', '$_POST[gname_$i]', '$_POST[menu1_$i]', '$_POST[menu2_$i]', '$_POST[menu3_$i]', '$_POST[menu4_$i]', '2')");
}
?>