Home > Database > Mysql Tutorial > mysql-sprintf_s 问题,求助

mysql-sprintf_s 问题,求助

WBOY
Release: 2016-06-06 09:38:56
Original
1742 people have browsed it

mysqlvs2008sprintf_s

组装一条mysql语句:
sprintf_s(strSql, "INSERT INTO twifibox_runninglogs VALUES
(NULL,'%u', '%s', FROM_UNIXTIME('%u'), '%.1f', '%.1f', '%d', '%d', NULL)\r\n",
DeviceId, RoomID, time(NULL), (float)pTh->s16CurRoomTemp/10,
(float)pTh->s16TrgRoomTemp/10, pTh->u8WarmState, pTh->WorkMode);

日志打印:
INSERT INTO twifibox_runninglogs VALUES (NULL,'589923834', '232985fa',
FROM_UNIXTIME('1439538081'), '0.0', '0.0', '1077215232', '0', NULL)

FROM_UNIXTIME('%u') 后面的全部错误,调试跟踪了:
pTh->s16CurRoomTemp = 252
pTh->s16TrgRoomTemp = 350
pTh->u8WarmState = 0
pTh->WorkMode = 1

看了很多遍,没发现有不妥的地方,参数都对齐了,求帮助
time(NULL) 不能直接用,得先用临时值保存?或者%u的格式用错了?
但是其他地方同样的用法又没出错

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template