gpt4 book ai didi

php - 更新语句错误

转载 作者:太空宇宙 更新时间:2023-11-03 11:09:52 25 4
gpt4 key购买 nike

我收到警告:mysql_affected_rows() 期望参数为资源, bool 值在 c:\program files\EasyPHP ......第 71 行中给出。

当我检查数据库时,该行已更新,但我仍然收到此错误消息

第 71 行是 if ($duplicates < 0);

 $query = mysql_query("UPDATE courses 
SET
course_code = '".$course_code."',
course_title = '".$course_title."' ,
course_unit = '".$course_unit."'
WHERE
course_code = '".$course_code."'")
or die(mysql_error());

$duplicates = mysql_affected_rows($query);
if ($duplicates > 0)


echo"<div id=\"contentRight\">";
echo"<idv id=\"msg\">" ; echo "You have a updated one Course " ;

echo"</div>" ;
echo"</div>" ;
exit();

最佳答案

与许多其他 mySQL 函数不同,mysql_affected_rows()不将查询资源作为第一个参数:它返回上次操作中受影响的行数,无论何时发生。

int mysql_affected_rows ([ resource $link_identifier ] )

您可以选择性地传递给它的是数据库连接 资源。但只有当您处理其中不止一个时,才有必要这样做。

关于php - 更新语句错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9297393/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com