Problem Inserting Date in Mysql from PHP

Discussion in 'PHP' started by mandarj123, Mar 27, 2009.

  1. #1
    $date=date('Y-j-m H:i:s ',ftp_mdtm($ftp,filename))
    mysql_query("INSERT INTO `` (`modifieddate`) VALUES ('".$date."')");

    i have used above code, my datatype in database is currently timestamp. i hav also used datetime but still the value in database of date shows 0000-00-00 00:00:00

    i am not getting whys tht happening please helpp
     
    mandarj123, Mar 27, 2009 IP
  2. steelaz

    steelaz Peon

    Messages:
    47
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    First, I think correct format for mysql datetime is "Y-m-d H:i:s". Second, your table name is missing. Try something like this:

    
    $date = date('Y-m-d H:i:s',ftp_mdtm($ftp,filename));
    mysql_query("INSERT INTO `table_name` (`modifieddate`) VALUES ('".$date."')"); 
    
    PHP:
     
    steelaz, Mar 27, 2009 IP
  3. mandarj123

    mandarj123 Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thnx mate it worked
     
    mandarj123, Mar 27, 2009 IP
  4. mandarj123

    mandarj123 Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    how to fetch a data from a field from mysql table in php
    i have taken result of select querry in $result variable wht to do next
     
    mandarj123, Mar 27, 2009 IP