SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: date

  1. #1
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    date

    I read in a thread I searched for this that to insert the current date into a database you can use curdate()

    This is my code:

    PHP Code:
    $insertnews "INSERT into news set date='CURDATE()', title = '$newstitle', content='$newstext', link='news.php?id=\$id', who='$username'"
    However, all it is doing is putting in 0000-00-00.

    Why?
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  2. #2
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    since you have quotes around CURDATE() you are inserting the STRING "CURDATE()". that STRING doesn't look like a DATE, so the default 0 value is used. take the quotes out and it'll be fine. e.g. ... SET date=CURDATE(), ...
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  3. #3
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by DR_LaRRY_PEpPeR
    since you have quotes around CURDATE() you are inserting the STRING "CURDATE()". that STRING doesn't look like a DATE, so the default 0 value is used. take the quotes out and it'll be fine. e.g. ... SET date=CURDATE(), ...
    aha! i'll give it a go. Cheers!
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky


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
  •