SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Jul 2006
    Location
    Fionnphort, Isle of Mull, Scotland
    Posts
    348
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Is 'dec' a reserved word in MySQL ?

    I have a MySQL table which records data (clicks on links, as it happens, but I don't think that has anything to do with my problem). The table has columns for each month, named 'jan', 'feb', ....'nov', 'dec'. Everything has been working perfectly since May, until we got to December. I find that nothing gets recorded in my column named 'dec', but if I name it something else (say, 'Decm') there's no longer any problem. (Although 'Dec' doesn't work).

    Two crucial lines of code are:-
    Code:
    $month = strtolower(date("M"));	//Sets month column for click (e.g. 'jan')
    this suits the column names I've chosen, so resorting to 'Decm' would be a pain. And:
    Code:
    $query1= "UPDATE memclicks SET $month=$month+1 where bus_id =" . $_GET['id'];
    Here the same '$month' variable represents the VALUE in the field, which is incremented by 1.

    As said, this has worked fine for all months May-Nov (and for Jan too), but NOT 'dec'. However, if I put back-ticks around the $month variable, it DOES work for 'dec' :-
    Code:
    $query1= "UPDATE memclicks SET `$month`=`$month`+1 where bus_id =" . $_GET['id'];
    Which is why I wonder if 'dec' is a reserved word ? Or is there something else ?

    Best Wishes for the New Year, everyone.
    Tim Dawson
    Isle of Mull, Scotland

  2. #2
    Non-Member
    Join Date
    Dec 2010
    Location
    /home/pc
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ramasaig View Post
    Which is why I wonder if 'dec' is a reserved word ? Or is there something else ?

    Best Wishes for the New Year, everyone.
    Did you find it in the reserved words section of the mysql manual?

  3. #3
    SitePoint Addict
    Join Date
    Jul 2006
    Location
    Fionnphort, Isle of Mull, Scotland
    Posts
    348
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thank you.

    Yes, I did find it when I followed your link. I wasn't sure where to look before. So quite clearly 'dec' IS a reserved word, and will remain so.

    No more to be said !
    Tim Dawson
    Isle of Mull, Scotland


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •