开发者

MySQL Affected Rows - Help

开发者 https://www.devze.com 2023-03-28 13:35 出处:网络
When I try to run this: $s=mysql_query(\"INSERT INTO forum_topics (forum_id,userid,title,createtime,createip,last_post_user,last_post_userid,last_post_time) VALUES (\'$forum_cat_id\',\'$userid\',\'$t

When I try to run this:

$s=mysql_query("INSERT INTO forum_topics (forum_id,userid,title,createtime,createip,last_post_user,last_post_userid,last_post_time) VALUES ('$forum_cat_id','$userid','$title','$time','$ip','{$userdata['username']}','$userid','$time')");
        if(mysql_affected_rows($s) == 0)
            return 7;

I get the following error: Warning:

mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in "PATH/TO/FILE" on line 76

Why is that?

EDIT: (After I did the var_dum开发者_如何学Cp, it returned this):

bool(true) string(0) "" Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in "PATH/TO/SITE" on line 77


You don't need to pass $s into mysql_affected_rows() function


try without paassing nothing to mysq_affected_rows()

$s=mysql_query("INSERT INTO forum_topics (forum_id,userid,title,createtime,createip,last_post_user,last_post_userid,last_post_time) VALUES ('$forum_cat_id','$userid','$title','$time','$ip','{$userdata['username']}','$userid','$time')");
        if(mysql_affected_rows() == 0)

    return 7;


This is a very common error. The most common problem, your query is wrong.

Example: No of Columns do not match, a field requires '' around it and you are omitting that, you are insert wrong type of data into a field.

To better trouble shoot, spit out the error from php code using mysql_error() function.

To even trouble shoot it more, assign your query to a variable $query and print out that query. Run that in MySQL and see what error you get.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号