use*_*575 6 php mysql printf date-format
我想在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"));
Run Code Online (Sandbox Code Playgroud)
我收到的错误是:
“Warning: sprintf() [fun
ction.sprintf]: Too few arguments. Query was Empty”
Run Code Online (Sandbox Code Playgroud)
Plz的帮助
你必须使用额外的%'s来转义日期格式字符串,试试这个:
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"));
Run Code Online (Sandbox Code Playgroud)