简体   繁体   中英

how to add picked date in a table as a column in mysql?

I am trying to add picked date as a column using the following query. But it shows an error:

"Error in column alter :ALTER TABLE cse145takeattendance ADD '2017-11-17' date;"

how to overcome this?.

$date=$_POST['today'];
$alter="ALTER TABLE cse145takeattendance ADD '$date' date;";
mysqli_query($s,$alter) or die ("Error in column alter :$alter");  

You need back-ticks around attribute

Identifiers may begin with a digit but unless quoted may not consist solely of digits.

Which means you must quote it with back ticks like `2017-11-17`:

See http://dev.mysql.com/doc/refman/5.0/en/identifiers.html

纯数字不能成为表格的字段!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM