Page 1 of 1

creating a post made since last visit problem

Posted: Mon Feb 09, 2009 2:36 pm
by lukevrn
hi,

on a news program i made i want to allow my members to see what new articles were made since they last visited the site. pretty much what i want to do is exactly how phpbb and other bbs programs do.

now looking at them i applied the same method but it doesn't seem to work.

first off i added a column last_visit which would have the last time they visited the site(in time())

then i made it do a search with the following query:.

Code: Select all

SELECT * FROM metal_posts WHERE Date>='$last_visit'
now doing it that displayed 0 results every time no matter what. changed >= to <= just displayed all of the news articles.

so question is, what am i doing wrong?

to let you know all the dates on my program are in time() format so format issue isn't the problem here.

thanks

Re: creating a post made since last visit problem

Posted: Mon Feb 09, 2009 3:14 pm
by Benjamin

Code: Select all

 
SELECT * FROM metal_posts WHERE `Date` >='$last_visit'
 
I believe date is a reserved mysql keyword. Try it with backticks. Echo the query and try running it manually to verify that there are no syntax errors. Is $last_visit escaped?

Re: creating a post made since last visit problem

Posted: Tue Feb 10, 2009 3:26 am
by mattpointblank
I wish tools like phpMyAdmin wouldn't let you create columns with reserved variables for names. When I first started out I took hours figuring out that that was the reason my 'desc' (description) column wasn't working, or 'usage'...

Re: creating a post made since last visit problem

Posted: Tue Feb 10, 2009 12:28 pm
by Weirdan
astions wrote: I believe date is a reserved mysql keyword.
It is, but it's still allowed as unquoted identifier:
MySQL manual wrote: MySQL allows some keywords to be used as unquoted identifiers because many people previously used them. Examples are those in the following list:
  • ACTION
  • BIT
  • DATE
  • ENUM
  • NO
  • TEXT
  • TIME
  • TIMESTAMP