Hi

I have a little problem i'm trying to put a date into mysql but it doesn't seem to work.
I tried many fuctions but I think it's something small i don't know.

$birth = $birthyear . "-" . $birthmonth . "-" . $birthday;

i'm trying to put that into a mysql date value.

INSERT INTO userdata (name,birth,postcode,city,state,country,sexpref,lovestate) ".
"VALUES ('$name',UNIX_TIMESTAMP('$birth'),'$postcode','$city','$state','$country','$sexpref','$lovestate')";

i tried it with UNIX_TIMESTAMP without it.with other functions like DATE() or FROM_TIMESTAMP() but i doesn't work.

I keep getting 0000-00-00 in my database but i'm sure my date format is in Y-m-d.

please help 😕

    when doing this I get a time but it's wrong :glare:

    $birth = mktime(0,0,0,$birthmonth,$birthday,$birthyear);

    $qry="INSERT INTO userdata (name,birth,postcode,city,state,country,sexpref,lovestate) ".
    "VALUES ('$name',FROM_UNIXTIME('$birth'),'$postcode','$city','$state','$country','$sexpref','$lovestate')";

    I also need times before Unix epoch.

      //Y-m-d is already mysql date format
      
      $birth = $birthyear . "-" . $birthmonth . "-" . $birthday;
      
      $sql = "INSERT INTO userdata (name,birth,postcode,city,state,country,sexpref,lovestate) 
       VALUES ('$name','$birth', '$postcode','$city','$state','$country','$sexpref','$lovestate')";
      

        Yes I knew but after searching a long time I just realised that my variable wasn't declared global and I used an other function to query my DB.
        so the value posted was null :queasy:

        Arrgh

          Write a Reply...