Results 1 to 6 of 6

Thread: Easy date question

  1. #1
    scoutt
    Guest
    hehe you can't do it that way.

    $query = "INSERT INTO Guests (UserName, Email, Comments, date("Ymd")) Values('$UserName', '$Email', '$Comments', '$Date')";


    date("Y-m-d") is a value not the name of the field. so do it like this


    $query = "INSERT INTO Guests (UserName, Email, Comments, date)) Values('$UserName', '$Email', '$Comments', 'date("Y-m-d") ')";

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Shouldn't it be:

    PHP Code:
    $query "INSERT INTO Guests (UserName, Email, Comments, date)) Values('$UserName', '$Email', '$Comments', 'date(\"Y-m-d\")')"
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    scoutt
    Guest
    very possible. if it doesn't work the way I have it you can try hobos way. or you can try this


    $query = "INSERT INTO Guests (UserName, Email, Comments, date)) Values('$UserName', '$Email', '$Comments', '".date("Y-m-d")."')";

  4. #4
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    OK, some of them worked kind of and some didn't work at all. The ones that worked kind of would add the record, but the date would be 0000-00-00.

    This is the one that worked from sscout sans a stray parenthesis.

    $query = "INSERT INTO Guests(UserName, Email, Comments, Date) Values('$UserName', '$Email', '$Comments', '".date("Y-m-d")."')";

    What are the "dots" doing? Why does this work?

  5. #5
    scoutt
    Guest
    well it is hard to say. but the . makes it so it leaves the anotation of the select statement and lets you use " in the code. kind of like adding it to itself.


    echo "todayts date = ". date("y-m-d") ;

    does pretty much the samething. does tha tmake sense?

  6. #6
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    Not to me

    Thanks for trying and at least it works. I'll figure it out eventually.

Posting Permissions

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



Click Here to Expand Forum to Full Width