提供的参数不是有效的 MySQL 结果
我的网络应用程序中收到 PHP 警告。我有点菜鸟。 我想根据每个用户配置文件中的“调整时区”整数向“更新”时间戳添加时区偏移量?
这是代码:
$timezonequery = mysql_query('SELECT adjusttimezone FROM members WHERE member_id=' . $_SESSION["myid"]);
$timezone = (int)mysql_result('$timezonequery', 0);
$updatedquery = mysql_query('SELECT DATE_ADD(updated, INTERVAL ' . $timezone . ' HOUR) FROM projects WHERE project_id=' . $i);
它有效,但我担心这个警告:
警告:mysql_result():已提供 参数不是有效的 MySQL 结果 xxx.php 第 9 行的资源
有人可以帮忙吗?谢谢
I've got a PHP warning in my web app. I'm a bit of a noob.
I want to add a timezone offset to the 'updated' timestamp based on the 'adjusttimezone' integer in each user's profile?
This is the code:
$timezonequery = mysql_query('SELECT adjusttimezone FROM members WHERE member_id=' . $_SESSION["myid"]);
$timezone = (int)mysql_result('$timezonequery', 0);
$updatedquery = mysql_query('SELECT DATE_ADD(updated, INTERVAL ' . $timezone . ' HOUR) FROM projects WHERE project_id=' . $i);
It works, but I'm worried about this warning:
Warning: mysql_result(): supplied
argument is not a valid MySQL result
resource in xxx.php on line 9
Can anyone help? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将 $timezonequery 作为字符串传递,它需要 mysql 资源。从 mysql_result 调用中删除引号:
You are passing $timezonequery as a string, it is expecting a mysql resource. Remove the quotes from your mysql_result call: