I have some codes and cannot insert to my db: My submit form: <tr> <td>Condition:</td> <td> <input type="radio" name="condition" value="U" CHECKED> Used <input type="radio" name="condition" value="N"> New </td> </tr> PHP: I insert into my db: $sql_insert = "INSERT into `items` (`condition` ) VALUES ($_POST[condition] ) "; mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error()); PHP: Then I got this: Why?
may be u forgot to add quotes to it : $sql_insert = "INSERT into items ('condition') VALUES ('$_POST['condition']')"; mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error()) PHP: see if this works.
You forgot the quotes. $sql_insert = "INSERT into `items` (`condition` ) VALUES ('$_POST[condition]' ) "; mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error()); PHP: I also suggest against inserting $_POST[condition] directly into DB, you usually want to filter any User input to prevent XSS/SQL injections.