Jump to content


Photo

insert timestamp onto database problem


  • Please log in to reply
30 replies to this topic

#21 marcus

marcus
  • Members
  • PipPipPip
  • Advanced Member
  • 1,842 posts
  • LocationRochester, NY

Posted 05 October 2006 - 11:21 PM

$query = "INSERT INTO onlineform (name,Cname,email,query,Pnumber,date) VALUES ('$name','$Cname','$email','$Query', '$Pnumber', '$date')";

try that

#22 2wasted

2wasted
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 05 October 2006 - 11:21 PM

is id primary key w/ auto_increment?

yeah m8

#23 2wasted

2wasted
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 05 October 2006 - 11:23 PM

$query = "INSERT INTO onlineform (name,Cname,email,query,Pnumber,date) VALUES ('$name','$Cname','$email','$Query', '$Pnumber', '$date')";

try that

still the same m8

#24 Skatecrazy1

Skatecrazy1
  • Members
  • PipPipPip
  • Advanced Member
  • 126 posts
  • LocationSouthern California

Posted 05 October 2006 - 11:24 PM

my god, why is there such a big problem on this

just do it EXACTLY like this

copy the variable code I give you

this is how I did it on my news script

$timestamp = date('M j, Y  g:i A');

then just insert $timestamp into your date field

it's very simple actually.
fuck it or fight it

#25 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 05 October 2006 - 11:26 PM

hes not posting show date is he.

$showdate=$_POST['showdate'];
$date=$_POST['date'];
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#26 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 05 October 2006 - 11:26 PM

You need to convert the time in php to a format MySQL can recognise...

$date = time(); as suggested will not give you a valid date format in MySQL.  Do you just want a current timestamp, if so, use this:

<?php
$query = "INSERT INTO onlineform (name, Cname, email, query, Pnumber, date) VALUES ('$Name','$Cname','$email','$Query', '$Pnumber', now())";
?>

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#27 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 05 October 2006 - 11:29 PM

$showdate = date('M j, Y  g:i A');
$showdate=strtotime($showdate);

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#28 2wasted

2wasted
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 05 October 2006 - 11:32 PM

You need to convert the time in php to a format MySQL can recognise...

$date = time(); as suggested will not give you a valid date format in MySQL.  Do you just want a current timestamp, if so, use this:

<?php
$query = "INSERT INTO onlineform (name, Cname, email, query, Pnumber, date) VALUES ('$name','$Cname','$email','$Query', '$Pnumber', now())";
?>

Regards
Huggie

i think you have hit the nail on the head:-)it displays on the page but does not go in to the datamase(MYSQL)

#29 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 05 October 2006 - 11:34 PM

OK, so like I said, do you want a current timestamp in the timestamp field?

MySQL's now() function will do that, see my code above.

Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#30 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 05 October 2006 - 11:36 PM

is your form name set to submit cheek ok.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#31 2wasted

2wasted
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 05 October 2006 - 11:49 PM

OK, so like I said, do you want a current timestamp in the timestamp field?

MySQL's now() function will do that, see my code above.

Huggie

cheers m8,
works!!:-)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users