Question 1: Why do you have a closing "}" in your main script when there isn't an opening "{"? Seems like a parse-error waiting to happen to me 🙁
Okay, so since order is in fact a MySQL keyword what you had initially in your first set of code is fine 😉 So you can go back to that.
Your problem is the type of quotes you're using. Single quotes ( ' ) contain strings that the PHP engine will not parse. So variables won't automatically be replaced with their values. So when you try to write your sql string to the variable $sql, you're writing the literal string $delete instead of the "interpreted" value of the variable $delete. This is why 99.9% of SQL strings are written with double quotes ( " ) instead of single-quotes.
So if you do this:
$sql = "DELETE FROM `objects` WHERE `order` = $delete";
Then echo out $sql, you'll be in business 😉
Just a word of caution. You should always make sure what the user-input you receive is a form in which you expect it. Since it's an order, I'd expect it to be a numerical value. So the functions [man]int_val/man, [man]ctype_digit/man would help you get the integer value and make sure it's a digit respectively.
If you're dealing with a string (like a unique order name for a user) you should use [man]mysql_real_escape_string/man to help ensure that special MySQL characters are escaped and arbitrary SQL statements aren't run on your database 😉
EDIT: If you want to delete the row, you do need to run [man]mysql_query/man with that sql string as well, but I'm sure you know that 😉
EDIT II:
bpat1434 wrote:
Okay, so since order is in fact a MySQL keyword what you had initially in your first set of code is fine. So you can go back to that.
Just to clarify for anyone else who is not aware, using back-ticks ( ` ) with column names should be common practice. The back-ticks actually tell MySQL that the string between the ticks is not to be treated as a reserved word (reserved words being words like ORDER, SELECT, TIME, NOW, DATE, etc.).
Secondly, when using table-names and column names, typically the table-name is not encapsulated with quotes, and the column name is still surrounded by quotes. For example:
tablename.column