我有一个mysql查询返回多列中的值的总和。查询是正确的,当我将它包含在主页面中时,一切正常。但是,当我在另一个 页面中包含查询并返回总和并在主页面中打印它不工作时,该问题开始。php mysql查询功能不工作
下面是主要的页面调用:
require('totals.php');
$res_easyhint_total=easyhint_totals($currentpid);
print $res_easyhint_total;
//The above is contained in a while loop and current pid gets updated each time.
功能页面:
function easyhint_totals($currentpid){
require('connect.php');
$sql_easyhint_total = "SELECT sum(Coffee+Gift+Cools+Affection+Patience+Anger+EHignore) from whyangry.posts where Pid=$currentpid";
$res_easyhint_total=mysql_query($sql_easyhint_total,$con);
$res_easyhint_total=mysql_fetch_array($res_easyhint_total);
$res_easyhint_total=$res_easyhint_total[0];
return $res_easyhint_total;
}
我不明白是什么错误,请帮助。
定义不工作...它会抛出一个错误?意外的结果?如果是这样,结果/预期结果是什么? – sachleen
它没有给出任何结果。并且while循环卡在那里。 –
首先,你不应该在函数中包含文件......或者在循环中,如果这就是你正在做的。 – sachleen