Desired behavior: I have a form that is designed to take data and put it into a mySQL table. The desired outcome is to have users enter their data, and if one submission in a particular column is submitted, the new data for the entire row will overwrite the old data.
Current behavior: I am getting a syntax error when the form is submitted.
Preliminary notes: I realize this code has potential for injection but the form consists only of dropdowns and a date picker (no open fields). Plus, this will be used for a very small organization with very little tech savvy.
$sql = "INSERT INTO $usertable (library, reason, closedate, opendate) VALUES
('$library', '$reason', '$closedate', '$opendate')
ON DUPLICATE KEY UPDATE reason=$reason(reason),
closeDate=$closedate(closedate), openDate=$opendate(opendate)";
Error message: 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 'weather. (reason), closeDate=2018-07-18(closedate), openDate=2018-07-27(opendate' at line 2
Attempts to correct syntax: I have tried separating all of my ON DUPLICATE KEY parameters by parenthesis, apostrophes and both at the same time. I have also tried removing what is currently displayed in parenthesis out, because I have seen successful code work both ways.
I would really appreciate any suggestions, thank you!