tags:

views:

25

answers:

1

Hello,

I have a table which stores featured from and to for objects. I would like to unfeature an item via ajax.

The way I have decided todo that is to set any featured rows for an object called to -1 day from now so its no longer featured.

However my query isn't working.

UPDATE `Movie_Featured` SET `to` = DATE_SUB(CURDATE(), INTERVAL 1 DAY) WHERE id > 0 $where

Ideas? Thanks!

+1  A: 

You have a ';' before the where clause, in your query :

UPDATE ... INTERVAL 1 DAY); WHERE ...

I suppose you should remove that ';', because it's the character that's used to separate queries ; which means you actually have two queries, here :

  • UPDATEMovie_FeaturedSETto= DATE_SUB(CURDATE(), INTERVAL 1 DAY);
    • which is a valid query, but will update every lines of your tabale
  • and WHERE id > 0 $where
    • which is not a valid query, and will cause an SQL error.
Pascal MARTIN
UPDATE `Movie_Featured` SET `to` = DATE_SUB(CURDATE(), INTERVAL 1 DAY) WHERE id > 0Indeed ;( Whoopsie
azz0r
Having someone else look at your code often helps, in that kind of situations ;-)
Pascal MARTIN