heiiumzz;10957980 wrote:
for the right syntax to use near ') VALUES ( , ,
means that your sql statement looks like
INSERT INTO sale_items (`user_id`, `propertyType`, `itemDescription`,`Price`,
`purpose`,`itemAge`,)
VALUES ( , ,
So, you've either supplied null or an empty string for (at least) the first two values. Also, there is a trailing , after itemAgewhich should not be there.
To deal with the missing values, you will need to check your input data for validity, either aborting on no input, or by supplying default values.
if (isset($_POST['user_id'])) {
$user_id = (int) $_POST['user_id'];
}
else {
# error handling
}
$property_type = empty($_POST['property_type'] ? 'default' : $_POST['property_type'];
# and so on
In case you are using the same script both to show the form initially as well as dealing with post data, the reason for the missing data is that no data has yet been posted the first time the script runs. Also, checking if (isset($POST)) is pointless when the script is run through a webserver, since $POST is always set, albeit empty.
# either
if (!empty($_POST))
# or
if (isset($_POST['name_of_your_submit_button']))
# or
if (count($_POST))