Page 1 of 1

[SOLVED]Problem on gettin the date into the database

Posted: Tue Sep 05, 2006 8:33 am
by ryuuka
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hello 

As it's saying above i have a problem at getting the current date into the database
this is a MSSQL database with a possibility to use UBB this is the code
this is what i have so far

(personal code is cleared, company policy. ****** is the database)
(excluding the rest of the page, it's quite long)

Code: Select all

head("Services Invoer","m");
  
  

$datum=date("H i s d F Y");
  
  
if ((isset($_GET['save'])) && (isset($_GET['save']))) {
    $sql = "INSERT INTO ***** VALUES ('".$_POST['computernaam']. "',   '".$_POST['displaynaam']."',
                                                                                     '".$_POST['servicenaam']."',     '".$_POST['status']."',
                                                                                       '$datum',                    '".$_POST['controleren']."');";
    
$db->Execute($sql);

what i need for this to do is everytime something is added i need the current date to be added to the database.
what would also be nice is the current dat to be added to a text space but this isn't necessary.
The code itself works perfect but the problems started when i added the date variable.

if one of you needs the complete code to solve this pm me please


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Tue Sep 05, 2006 9:01 am
by jito
you should use a timestamp.

$sql="INSERT INTO ***** VALUES (...,now(),.......)";
use now() instead of $datum. check curtime(),curdate() functions of mysql.

Posted: Wed Sep 06, 2006 1:23 am
by ryuuka
thanks it works now

Posted: Wed Sep 06, 2006 3:00 am
by Ollie Saunders
If you want to insert arbitary dates ensure they are in YYYY-MM-DD HH:MM:SS format (w/ or w/o time bit)