mysql_affected_rows 给出“提供的参数不是有效的 MySQL-Link 资源";带有有效查询的错误 [英] mysql_affected_rows gives "supplied argument is not a valid MySQL-Link resource" error WITH VALID QUERY

查看:40
本文介绍了mysql_affected_rows 给出“提供的参数不是有效的 MySQL-Link 资源";带有有效查询的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题已发布 50 次,答案始终是您的查询有误".好吧,我的查询有效,我的数据库更新了值,但我仍然遇到 mysql_affected 行的问题.我的简化代码:

This question has been posted 50 times, and the answer is always "your query has an error". Well, my query is valid and my database is updated with values and I'm still having trouble with mysql_affected rows. My simplified code:

$sql = "UPDATE t_users
    SET t_users.facebookID = '$facebookID'
    WHERE t_users.username = '$username'";

$query = mysql_query($sql);

if ($query){
  if (mysql_affected_rows($query)) echo "success";
}
else echo "error registering account--error was " . mysql_error();

当我运行它时,facebookID 列会更新,但我收到警告:

When I run this, the facebookID column is updated, but I get a warning:

<b>Warning</b>:  mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource...

还有什么要检查的吗?

推荐答案

int mysql_affected_rows ([ resource $link_identifier = NULL ] )

mysql_affected_rows 应该是 mysql_connect 返回的资源,不是 mysql_query 返回的资源.或者可以完全省略.

The argument to mysql_affected_rows should be a resource returned by mysql_connect, not a resource returned by mysql_query. Or it could be omitted entirely.

这篇关于mysql_affected_rows 给出“提供的参数不是有效的 MySQL-Link 资源";带有有效查询的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆