这是我在屏幕上显示的错误。参数错误PHP
警告:mysqli_fetch_assoc()预计参数1被mysqli_result,在/home/mjcrawle/onlinebanking/viewaccounts.php空给出线52
我觉得我的错误可能是在我的while循环不能确定。不过,我认为我的代码的构造是正确的。
<?php
/*Accounts*/
$currentMember->connection = $conn;
$accounts = $currentMember->retrieve_all_accounts();
/*Loop thorugh account - Grabs data*/
while($account = mysqli_fetch_assoc($accounts)){
/*Retrieve Balance*/
$bankaccount = new Bankaccount($account['BankAccountID']);
$bankaccount->connection = $conn;
$balance = mysqli_fetch_assoc($bankaccount->retrieve_current_balance());
echo '<tr>' . "\n";
echo "\t" . '<td>' . $account['BankAccountID'] . '</td>' . "\n";
echo "\t" . '<td>$' . number_format($balance['CurrentBalance'], 2) . '</td>' . "\n";
echo '<tr>' . "\n";
}
/*Close DB*/
mysqli_close($db->connection);
?>
</tbody>
</table>
</div><!--End of main content-->
<?php
include(ABSOLUTE_PATH . 'footer.inc.php');
?>
</div><!--end of header-->
显然你的'retrieve_current_balance'方法返回'null'。找出为什么。 – Jon 2012-04-07 16:52:53
你确定它在'while'循环吗?当我在急着调试时,我总是使用'die()',并带有一条消息说明它在哪里(即“我在while循环之前!”)。你可以使用'instanceof'类型操作符(http://php.net/manual/en/language.operators.type.php)来确保'$ accounts'和'$ bankaccount-> retrieve_current_balance()'是'mysqli_result'类。 – 2012-04-07 16:56:42