简体   繁体   中英

Date being changed when updating MySQL field

I'm running into a weird issue where I'm posting a date in Ymd format yet it's being changed to a completely different date once I view in the actual MySQL table.

Here's the query

UPDATE $admins_table 
SET    expire=$expireu 
WHERE  identity='$donation_row[steam_id]

The expire field is what I'm having issues with. The field itself is a varchar, and the $expireu variable is always a date in Ymd format ex. 2013-11-16

When that query is run, with the date I gave as an example above, I get a weird result in the actual MySQL table. If I go to view the table, instead of it storing 2013-11-16 it has stored 1986 as the date. No month or day, just 1986 .

I may have made a very stupid/silly mistake, but at this point I'm unsure of what I've flubbed. Any help in the right direction would be much appreciated, thank you.

haha, use quotes!

UPDATE $admins_table SET expire='$expireu' WHERE identity='$donation_row[steam_id]'

mysql substracts 2013-11-16 == 1986

使用'和'是您的朋友。您正在将一个数学问题传递到正在解决的mysql中,然后保存结果。

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