Page 1 of 1
current date
Posted: Tue Jul 08, 2003 8:11 am
by irealms
i have an insert query and one the variables i want to end is the current date, how would i do this?
Posted: Tue Jul 08, 2003 8:14 am
by DuFF
If the field is the date type then using the PHP function NOW() will work fine.
Posted: Tue Jul 08, 2003 8:36 am
by irealms
so my query would be?
$newuploadquery = "INSERT INTO groups (groupname,username,dateadded,uploadedfile) VALUES ('$_SESSION[groupname],'$_SESSION[valid_user]','NOW()'";
Posted: Tue Jul 08, 2003 8:46 am
by DuFF
Delete the quotes around NOW(). Example of mine that works:
query = "INSERT INTO files VALUES ('','$file','$category','0','0','0',NOW(),'$review')";
Posted: Tue Jul 08, 2003 8:57 am
by irealms
still getting error with
$newuploadquery = "INSERT INTO uploads (groupname,username,dateadded,uploadedfile) VALUES ('$_SESSION[groupname],'$_SESSION[valid_user]',NOW(),'$file_name')";
now error is :
query [INSERT INTO uploads (groupname,username,dateadded,uploadedfile) VALUES ('admin,'osmadmin-ryan',NOW(),'corgonsblade.jpg')] failed: You have an error in your SQL syntax near 'osmadmin-ryan',NOW(),'corgonsblade.jpg')' at line 1
Posted: Tue Jul 08, 2003 8:59 am
by irealms
when i tried:
$currentdate = NOW();
$newuploadquery = "INSERT INTO uploads (groupname,username,dateadded,uploadedfile) VALUES ('$_SESSION[groupname],'$_SESSION[valid_user]','$currentdate','$file_name')";
i got an undefined function error
Posted: Tue Jul 08, 2003 9:15 am
by irealms
also tried using
$currentdate = date("Y-d-m");
which seems to show the right date but i'm getting a syntax error
Posted: Tue Jul 08, 2003 9:16 am
by irealms
woot it works, was missing a '