2wasted Posted October 5, 2006 Share Posted October 5, 2006 lo all,i have a form that goes to a database, everthing works fine except the timestamp says 0000-00-00 00:00:00 .i have tryed changing the value in the mysql from timestamp to date but still is'nt working...i have displayed the date on my page np...here is the code?PHP $Name=$_POST['name']; $Cname=$_POST['cname']; $Query=$_POST['Question']; $email=$_POST['email']; $Pnumber=$_POST['Pnumber']; $date = time(); $showdate = date("H:i:s d/m/Y");mysql_select_db($database_csc, $csc);$query_Recordset1 = "SELECT * FROM onlineform";$Recordset1 = mysql_query($query_Recordset1, $csc) or die(mysql_error());$row_Recordset1 = mysql_fetch_assoc($Recordset1);$totalRows_Recordset1 = mysql_num_rows($Recordset1);$query_Recordset1 or die( "Unable to select database");if($_POST['submit']) {$query = "INSERT INTO onlineform VALUES ('','$name','$Cname','$email','$Query', '$Pnumber', '$date')";mysql_query($query);mysql_close(); echo "<h2>THank you for filling in this form, we will be in touch with you ASAP</h2>"; echo $showdate;}?>Thanks for any helpCharlie Quote Link to comment Share on other sites More sharing options...
marcus Posted October 5, 2006 Share Posted October 5, 2006 [code]$showdate = date("F j, Y, g:i a");[/code]It'll show like "October 5, 2006, 5:29 pm" Quote Link to comment Share on other sites More sharing options...
2wasted Posted October 5, 2006 Author Share Posted October 5, 2006 the show date on the page works..it just does'nt go into the DB.thxCharlie Quote Link to comment Share on other sites More sharing options...
marcus Posted October 5, 2006 Share Posted October 5, 2006 well, how are you submitting it? because if i'm right your sql is incorrect[code]$query = "INSERT INTO onlineform VALUES ('','$name','$Cname','$email','$Query', '$Pnumber', '$date')";[/code]should be:[code]$query = "INSERT INTO onlineform VALUES ('','$name','$Cname','$email','$Query', '$Pnumber', '$showdate')";[/code] Quote Link to comment Share on other sites More sharing options...
2wasted Posted October 5, 2006 Author Share Posted October 5, 2006 tryed that still 0000-00-00 00:00:00thxCharlie Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 5, 2006 Share Posted October 5, 2006 [code]$query = "INSERT INTO onlineform VALUES ('$name','$Cname','$email','$Query', '$Pnumber', '$date')";mysql_query($query);[/code] Quote Link to comment Share on other sites More sharing options...
2wasted Posted October 5, 2006 Author Share Posted October 5, 2006 i took out the echo $showdate; and it still never worked. i have tryed values of date×tamp in the mysql database structure, could i use another?Charlie Quote Link to comment Share on other sites More sharing options...
marcus Posted October 5, 2006 Share Posted October 5, 2006 that's what he has.did you change the $showdate to [code]$showdate = date("F j, Y, g:i a");[/code]do that, then edit your sql[code]$query = "INSERT INTO onlineform VALUES ('$name','$Cname','$email','$Query', '$Pnumber', '$showdate')";mysql_query($query);[/code]you had $date while $date = time();, showdate is the date Quote Link to comment Share on other sites More sharing options...
marcus Posted October 5, 2006 Share Posted October 5, 2006 if you have a form do:[code]<input type=hidden value='<?php echo $showdate ?>'>[/code] Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 5, 2006 Share Posted October 5, 2006 you got the insert set as date so you need to set $date=date();dont you.you got showdate but the insert looking for $date. Quote Link to comment Share on other sites More sharing options...
marcus Posted October 5, 2006 Share Posted October 5, 2006 he has:$date = time();and $showdate = date(); Quote Link to comment Share on other sites More sharing options...
marcus Posted October 5, 2006 Share Posted October 5, 2006 this should be your final code[code]<?PHP $Name=$_POST['name']; $Cname=$_POST['cname']; $Query=$_POST['Question']; $email=$_POST['email']; $Pnumber=$_POST['Pnumber']; $date = time(); $showdate = date("F j, Y, g:i a");mysql_select_db($database_csc, $csc);$query_Recordset1 = "SELECT * FROM onlineform";$Recordset1 = mysql_query($query_Recordset1, $csc) or die(mysql_error());$row_Recordset1 = mysql_fetch_assoc($Recordset1);$totalRows_Recordset1 = mysql_num_rows($Recordset1);$query_Recordset1 or die( "Unable to select database");if($_POST['submit']) {$query = "INSERT INTO onlineform VALUES ('','$name','$Cname','$email','$Query', '$Pnumber', '$showdate')";mysql_query($query);mysql_close(); echo "<h2>THank you for filling in this form, we will be in touch with you ASAP</h2>"; echo $showdate;}?>[/code] Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 5, 2006 Share Posted October 5, 2006 I have had a good look know and your insert is wrong as the insert has to be in the same order as the database and yours isint.have a look at you database field order and match aginst you insert on here the order i think is wrong sorry. Quote Link to comment Share on other sites More sharing options...
2wasted Posted October 5, 2006 Author Share Posted October 5, 2006 this is what i have changed it to and it still does'nt work $Name=$_POST['name']; $Cname=$_POST['cname']; $Query=$_POST['Question']; $email=$_POST['email']; $Pnumber=$_POST['Pnumber']; $date = time();$query = "INSERT INTO onlineform VALUES ('','$name','$Cname','$email','$Query', '$Pnumber', '$showdate')";mysql_query($query);mysql_close(); echo "<h2>THank you for filling in this form, we will be in touch with you ASAP</h2>"; //echo $showdate; Quote Link to comment Share on other sites More sharing options...
marcus Posted October 5, 2006 Share Posted October 5, 2006 copy my code Quote Link to comment Share on other sites More sharing options...
2wasted Posted October 5, 2006 Author Share Posted October 5, 2006 my inserts are the same order as my database m8 Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 5, 2006 Share Posted October 5, 2006 post your database please cheers. Quote Link to comment Share on other sites More sharing options...
2wasted Posted October 5, 2006 Author Share Posted October 5, 2006 id int name vacharCname varcharemail varcharquery varcharPnumber varchardate timestamp Quote Link to comment Share on other sites More sharing options...
marcus Posted October 5, 2006 Share Posted October 5, 2006 is id primary key w/ auto_increment? Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 5, 2006 Share Posted October 5, 2006 [code]<?php $Name=$_POST['name']; $Cname=$_POST['cname']; $Query=$_POST['Question']; $email=$_POST['email']; $Pnumber=$_POST['Pnumber']; $date = time(); $showdate = date("H:i:s d/m/Y");mysql_select_db($database_csc, $csc);$query_Recordset1 = "SELECT * FROM onlineform";$Recordset1 = mysql_query($query_Recordset1, $csc) or die(mysql_error());$row_Recordset1 = mysql_fetch_assoc($Recordset1);$totalRows_Recordset1 = mysql_num_rows($Recordset1);$query_Recordset1 or die( "Unable to select database");if($_POST['submit']) {$query = "INSERT INTO onlineform VALUES ('$id','$name','$Cname','$email','$Query', '$Pnumber', '$date')";mysql_query($query)or die("insert is dead");echo "<h2>THank you for filling in this form, we will be in touch with you ASAP</h2>"; echo $showdate;}?>[/code] Quote Link to comment Share on other sites More sharing options...
marcus Posted October 5, 2006 Share Posted October 5, 2006 [code]$query = "INSERT INTO onlineform (name,Cname,email,query,Pnumber,date) VALUES ('$name','$Cname','$email','$Query', '$Pnumber', '$date')";[/code]try that Quote Link to comment Share on other sites More sharing options...
2wasted Posted October 5, 2006 Author Share Posted October 5, 2006 [quote author=mgallforever link=topic=110633.msg447638#msg447638 date=1160090242]is id primary key w/ auto_increment?[/quote]yeah m8 Quote Link to comment Share on other sites More sharing options...
2wasted Posted October 5, 2006 Author Share Posted October 5, 2006 [quote author=mgallforever link=topic=110633.msg447643#msg447643 date=1160090496][code]$query = "INSERT INTO onlineform (name,Cname,email,query,Pnumber,date) VALUES ('$name','$Cname','$email','$Query', '$Pnumber', '$date')";[/code]try that[/quote]still the same m8 Quote Link to comment Share on other sites More sharing options...
Skatecrazy1 Posted October 5, 2006 Share Posted October 5, 2006 my god, why is there such a big problem on thisjust do it EXACTLY like thiscopy the variable code I give youthis is how I did it on my news script[code]$timestamp = date('M j, Y g:i A');[/code]then just insert $timestamp into your date fieldit's very simple actually. Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 5, 2006 Share Posted October 5, 2006 hes not posting show date is he.$showdate=$_POST['showdate'];$date=$_POST['date']; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.