[SOLVED]Problem on gettin the date into the database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ryuuka
Forum Contributor
Posts: 128
Joined: Tue Sep 05, 2006 8:18 am
Location: the netherlands

[SOLVED]Problem on gettin the date into the database

Post 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]
Last edited by ryuuka on Wed Sep 06, 2006 3:35 am, edited 1 time in total.
jito
Forum Commoner
Posts: 85
Joined: Sat Mar 25, 2006 4:32 am
Location: india

Post by jito »

you should use a timestamp.

$sql="INSERT INTO ***** VALUES (...,now(),.......)";
use now() instead of $datum. check curtime(),curdate() functions of mysql.
ryuuka
Forum Contributor
Posts: 128
Joined: Tue Sep 05, 2006 8:18 am
Location: the netherlands

Post by ryuuka »

thanks it works now
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post 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)
Post Reply