I've been messing around with SQL And PHP recently and I've come into another problem which has blown all logic out for me.
I have this form:
System Type <select name="systype"> <option value="systype1">type1</option> <option value="systype2">type2</option> <option value="systype3">type3</option> <option value="systype4">type4</option> <option value="none" selected="selected">None</option> </select><br>
This form will send whatever is selected to the database. Or so I thought...
This is the main snippet of my PHP
// Note that whatever is enclosed by $_POST[""] matches the form input elements // $Value_name = $_POST["Form_Name"]; $value_customer_name = $_POST["customer_name"]; $value_customer_name_letterhead = $_POST["customer_name_letterhead"]; $value_customer_notes = $_POST["customer_notes"]; $value_systype = $_POST["systype"]; // Connect to our DB with mysql_connect(<server>, <username>, <password>) $sql_connection = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die(mysql_error()); mysql_select_db(DB_NAME , $sql_connection) or die(mysql_error()); $sql = "INSERT INTO Customers( customer_name, customer_name_letterhead, customer_notes systype ) VALUES ( '$value_customer_name', '$value_customer_name_letterhead', '$value_customer_notes', '$value_systype' )";
However, when I put
Test, Test, Test in all of the customer sections and then leave systype as None.
I recieve this error:
Error: 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 'systype ) VALUES ( 'test', 'test', ' at line 5