Hey… so I attempted to run the query below and it just won’t do it. I’ve checked:
- The number of fields in the form matches the number of fields in the table.
- The number of session variables matches those numbers too.
- That the actual query contains the data to be input with an echo.
- That the table name is correct.
- That queries work with other tables in the same database (they DO).
- Used or die(mysql_error(); to get the “Incorrect syntax” error.
- Rebuilt the table several times.
Here’s the line that’s apparently syntactically problematic, if you can see anything wrong with it or point me in the right direction I’d be super greatful as I’m at a loss now! Might it be a memory issue?
$sql = "INSERT INTO careBoiler (buyerID, date, sector, require, boilerMake, boilerModel, boilerType, heating, visit, deadline, budget, currcompany, specificreq) VALUES ('{$_SESSION['buyerID']}', now(), '{$_SESSION['cb']['sector']}', '{$_SESSION['cb']['require']}', '{$_SESSION['cb']['boilerMake']}', '{$_SESSION['cb']['boilerModel']}', '{$_SESSION['cb']['boilerType']}', '{$_SESSION['cb']['heating']}', '{$_SESSION['cb']['visit']}', '{$_SESSION['cb']['deadline']}', '{$_SESSION['cb']['budget']}', '{$_SESSION['cb']['currcompany']}', '{$_SESSION['cb']['specificreq']}')";
Looks like
requireis a MySQL reserved word which you are using as a column name.To fix this you can either choose a different column name or place it in back ticks as: