tags:

views:

121

answers:

3

Basically I want to put "todays" year, month, day into two fields ... something like the following. Tried varients of but cant get it right

"INSERT INTO film_out (start_year, start_month, start_day), (end_year, end_month, end_day) VALUES ('$year', '$month', '$day') "

+2  A: 

?

"INSERT INTO film_out (start_year, start_month, start_day, end_year, end_month, end_day)
      VALUES ('$year', '$month', '$day', '$year', '$month', '$day')"

EDIT: I'd love to hear why people are downvoting this...

cLFlaVA
it's a mysql question. see @feed.transisted.com's answer.
nickf
@nickf I see it. Not sure why the solution I provided wouldn't work. I took the OP's sample code, which evidently employs some PHP to store day, year and month variables, and plugs them (albeit not safely) into a query. I simply showed him the correct query form.
cLFlaVA
+2  A: 
INSERT INTO film_out 
(start_year, start_month, start_day, end_year, end_month, end_day) 
VALUES 
(?,?,?,?,?,?)

You have six columns, so you need six values.

If you have two sets of three values, you need to repeat the same values.

You want to use bind variables instead of direct interpolation (? instead of '$year').

Thilo
+1  A: 

Not sure what your column types are so I'm assuming they are numeric...

INSERT INTO film_out (start_year, start_month, start_day, end_year, end_month, end_day)
VALUES (YEAR(), MONTH(NOW()), DAYOFMONTH() + 1, YEAR(), MONTH(NOW()), DAYOFMONTH() + 1)
Tautologistics