Thread: query is wrong?

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    29
    Rep Power
    0
    This is related to php too:

    $sqlQuery = "Select *, MONTHNAME('dateSigned') as month from guestbook ORDER BY name";
    $result = mysql_query($sqlQuery, $db) or die("Unable to query database.");
    while($myrow = mysql_fetch_array($result)) {
    $dateSigned = $myrow["month"];

    printf("Date: %sn", $dateSigned);
    }
    ?>

    the field dateSigned is a date field. (2000etcetcetc) so all i want to do is extract the month from this. Shouldn't It make a temporary field so all i have to do is use "month"?????????? $myrow["month"] is always empty :/

    Thanks in advance!

    Cisk
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    You need to remove the single quotes from around dateSigned in the MONTHNAME function. When referring to a column name NEVER use quotes. Using quotes tells MySQL to perform the function on what's in the quotes, NOT on the contents of the field.

Similar Threads

  1. Syntax error in INSERT INTO query
    By Lee Miles in forum Visual Basic Programming
    Replies: 6
    Last Post: December 19th, 2003, 08:37 AM
  2. whats wrong with this query ?
    By entropia in forum MySQL Help
    Replies: 2
    Last Post: August 4th, 2003, 12:17 PM
  3. sql query wots wrong?
    By Lyreco in forum MySQL Help
    Replies: 1
    Last Post: July 26th, 2003, 09:04 AM
  4. SQL query form
    By Phönix in forum MySQL Help
    Replies: 2
    Last Post: July 20th, 2003, 04:31 AM
  5. Whats wrong with this query?
    By pathogen in forum MySQL Help
    Replies: 2
    Last Post: May 3rd, 2002, 10:18 AM

IMN logo majestic logo threadwatch logo seochat tools logo