gpt4 book ai didi

php - mysql查询: date_format and sprintf()

转载 作者:可可西里 更新时间:2023-11-01 06:44:14 25 4
gpt4 key购买 nike

我想在 MySQL 查询中使用 sprintf() 和 date_format。

这里是查询:

mysql_select_db($database_exdb, $expdb);
$query_eventeditrs = sprintf("SELECT eventid, groupid, title, DATE_FORMAT(dateofevent, '%W, %M %d, %Y'), timeofevent, location, details, presenter, bio FROM events WHERE eventid = %s", GetSQLValueString($colname_eventeditrs, "int"));

我得到的错误是:

“Warning: sprintf() [fun
ction.sprintf]: Too few arguments. Query was Empty”

请帮忙

最佳答案

你必须用额外的 % 来转义日期格式字符串,试试这个:

sprintf("SELECT eventid, groupid, title, 
DATE_FORMAT(dateofevent, '%%W, %%M %%d, %%Y'),
ti meofevent, location, details, presenter, bio
FROM events
WHERE eventid = %s", GetSQLValueString($colname_eventeditrs, "int"));

关于php - mysql查询: date_format and sprintf(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5835534/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com