Hi all you mysql and perl gurus!
I have code that looks like $store = qq(INSERT INTO main (release_date) VALUES(DATE_ADD(NOW(), INTERVAL 1 DAY))
It works perfectly. The problem is I need to find a way to use a variable instead of "INTERVAL 1 DAY". This value is coming from a form and has about 12 options (ie: 1 Day, 2 Day, 1 Week, 2 Week).
I'm currently using 12 different if/elsif conditions based on the form variables so the code right now is really bulky.
I'm trying to get something like this to work var timeframe = ""; if ($data{date_field} == "1 Week") { $timeframe = "1 WEEK"; } . . $store = qq(INSERT INTO main (release_date) VALUES(DATE_ADD(NOW(), INTERVAL "$timeframe"))
But it errors out saying I have a MySQL syntax problem.
Anyone know what I have to do to get this to work so I can shorten the code a bit?
prepareonly once.