-4

I am trying to submit a order form into a database, it's supposed to work in theory but for some reason isn't showing up in the table on the database.

$result = "insert into orders(lastname, id, email, roomnumber, typeorder)
    values('".$lastname ."','".$ID ."','".$Email ."','".$RoomNumber ."','".$typeorder ."','" . "0');";
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • You need to post the complete code that you are using to insert, add error handling and show us what error you are getting. – jeroen Jan 02 '13 at 16:57
  • Are you using [**deprecated `mysql_` functions**](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php)? What does the rest of your code look like? – DCoder Jan 02 '13 at 16:57

2 Answers2

4

You're inserting 6 values for 5 columns... Remove the '0'

And please, don't use mysql_* instead try PDO.

nickb
  • 59,313
  • 13
  • 108
  • 143
Jeffrey
  • 1,239
  • 8
  • 15
0

I would recommend you using data sanitization before running the query anyway. but here is the quick fix and it should work absolutely fine.
$result = "insert into orders(lastname, id, email, roomnumber, typeorder) values('".$lastname ."','".$ID ."','".$Email ."','".$RoomNumber ."','".$typeorder ."')";

Abbasi
  • 125
  • 7