Posted: Tue Nov 28, 2006 2:19 pm
CURDATE() is a MySQL function.
Code: Select all
INSERT INTO `mytable` (`my_date`) VALUES (NOW());A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
INSERT INTO `mytable` (`my_date`) VALUES (NOW());Code: Select all
$sql="INSERT INTO $table_name (create_date) VALUES (NOW())";
Code: Select all
"INSERT INTO $table_name values('$_POST[merchant_num]',
'$_POST[date_recieved]',
'$_POST[merchant_name]',
'$_POST[purchase_type]',
'$_POST[lease_score]',
'$_POST[amex]',
'$_POST[app_id]',
'$_POST[discover]',
'$_POST[user_name]',
'$_POST[check_conversion]',
'$_POST[gift_loyalty]',
'$_POST[app_type]',
'$_POST[terminal]',
'$_POST[serial_num]',
'$_POST[nms]',
'$_POST[ckmerchant_num]',
'$_POST[giftmerchant_num]',
'$_POST[comments]',)";
$sql="INSERT INTO $table_name (create_date) VALUES (NOW())";Code: Select all
$sql = "INSERT INTO $table_name values ('{$_POST[merchant_num]}',
'{$_POST[date_recieved]}',
'{$_POST[merchant_name]}',
'{$_POST[purchase_type]}',
'{$_POST[lease_score]}',
'{$_POST[amex]}',
'{$_POST[app_id]}',
'{$_POST[discover]}',
'{$_POST[user_name]}',
'{$_POST[check_conversion]}',
'{$_POST[gift_loyalty]}',
'{$_POST[app_type]}',
'{$_POST[terminal]}',
'{$_POST[serial_num]}',
'{$_POST[nms]}',
'{$_POST[ckmerchant_num]}',
'{$_POST[giftmerchant_num]}',
'{$_POST[comments]}',)"; Notice: Use of undefined constant comments
Code: Select all
$sql = "INSERT INTO $table_name values('{'$_POST[merchant_num]'}',
'{'$_POST[date_recieved]'}',
'{'$_POST[merchant_name]'}',
'{'$_POST[purchase_type]'}',
'{'$_POST[lease_score]'}',
'{'$_POST[amex]'}',
'{'$_POST[app_id]'}',
'{'$_POST[discover]'}',
'{'$_POST[user_name]'}',
'{'$_POST[check_conversion]'}',
'{'$_POST[gift_loyalty]'}',
'{'$_POST[app_type]'}',
'{'$_POST[terminal]'}',
'{'$_POST[serial_num]'}',
'{'$_POST[nms]'}',
'{'$_POST[ckmerchant_num]'}',
'{'$_POST[giftmerchant_num]'}',
'{'$_POST[comments]'}')";
$sql="INSERT INTO $table_name (create_date) VALUES (NOW())";Code: Select all
$sql = "INSERT INTO $table_name values('{'$_POST[merchant_num]'}',
'{'$_POST[date_recieved]'}',
'{'$_POST[merchant_name]'}',
'{'$_POST[purchase_type]'}',
'{'$_POST[lease_score]'}',
'{'$_POST[amex]'}',
'{'$_POST[app_id]'}',
'{'$_POST[discover]'}',
'{'$_POST[user_name]'}',
'{'$_POST[check_conversion]'}',
'{'$_POST[gift_loyalty]'}',
'{'$_POST[app_type]'}',
'{'$_POST[terminal]'}',
'{'$_POST[serial_num]'}',
'{'$_POST[nms]'}',
'{'$_POST[ckmerchant_num]'}',
'{'$_POST[giftmerchant_num]'}',
'{'$_POST[comments]'}',
'{'$_POST[NOW()]'}')";Code: Select all
$sql = "INSERT INTO $table_name values ('{$_POST['merchant_num']}',
'{$_POST['date_recieved']}',
'{$_POST['merchant_name']}',
'{$_POST['purchase_type']}',
'{$_POST['lease_score']}',
'{$_POST['amex']}',
'{$_POST['app_id']}',
'{$_POST['discover']}',
'{$_POST['user_name']}',
'{$_POST['check_conversion']}',
'{$_POST['gift_loyalty']}',
'{$_POST['app_type']}',
'{$_POST['terminal']}',
'{$_POST['serial_num']}',
'{$_POST['nms']}',
'{$_POST['ckmerchant_num']}',
'{$_POST['giftmerchant_num']}',
'{$_POST['comments']}',
NOW())";Code: Select all
$yy = 2006;
for($mm=9; $mm<=12; $mm++){
for($dd=1; $dd<=30; $dd++){
$dt = $yy."-".$mm."-".$dd;
print $dt."\n";
$sql = "INSERT INTO tbl_dates(date_val) VALUES('$dt')";
mysql_query($sql, $cn) or die(mysql_error());
}
}Code: Select all
SELECT date_val FROM tbl_dates WHERE date_val<=DATE_SUB(CURDATE(), INTERVAL 30 DAY)Code: Select all
SELECT date_val FROM tbl_dates WHERE date_val=DATE_SUB(CURDATE(), INTERVAL 30 DAY)Code: Select all
Output :
2006-10-30thanks everah..that worked like a charm....also thanks for the clarity on the post...i knew it gathered the information from the form via the array but was uncertain of how it actually stored the info into the db....i just figured it played a double role...when i tried to do the now before like the way you have it there it was giving me whitespace errors...im guessing because of the closed paren alsoEverah wrote:$_POST is an array of information that comes from a form, not what you'd use to 'post' things to the database. NOW() is a MySQL function, not a PHP one. Try this and see what comes of it.EDIT | Was missing a closing paren at the end.Code: Select all
$sql = "INSERT INTO $table_name values ('{$_POST['merchant_num']}', '{$_POST['date_recieved']}', '{$_POST['merchant_name']}', '{$_POST['purchase_type']}', '{$_POST['lease_score']}', '{$_POST['amex']}', '{$_POST['app_id']}', '{$_POST['discover']}', '{$_POST['user_name']}', '{$_POST['check_conversion']}', '{$_POST['gift_loyalty']}', '{$_POST['app_type']}', '{$_POST['terminal']}', '{$_POST['serial_num']}', '{$_POST['nms']}', '{$_POST['ckmerchant_num']}', '{$_POST['giftmerchant_num']}', '{$_POST['comments']}', NOW())";
Code: Select all
SELECT create_date FROM merchant WHERE create_date<=DATE_SUB(CURDATE(), INTERVAL 30 DAY)
Code: Select all
Select * FROM merchant WHERE user_name = '{$_SESSION['logname']}'
Code: Select all
Select * FROM merchant WHERE user_name = '{$_SESSION['logname']}' AND WHERE create_date<=DATE_SUB(CURDATE(), INTERVAL 30 DAY)