错误是致命错误:在第72行的/home/mjcrawle/public_html/cit0215/assignment5/onlinebanking/viewaccounts.php中调用未定义的方法stdClass :: retrieve_all_accounts()
我没有收到任何HTML错误,所以我会把它留下来。
我的PHP代码错误是:
<?php
require_once('footer_nav/navigation.inc.php');
require_once('../websiteconfig.inc.php');
require_once('../class/person_class.php');
require_once('../class/database.class.php');
/*Start Session*/
session_start();
$currentMember =unserialize($_session['currentMember']);
/*DataBase*/
$db = new Database;
$conn = $db->connection;
?>
<td width="16"> </td>
<td width="595">
</td>
</tr>
</div>
<h2>Accounts</h2>
</td>
<table id="accounts" summary="Bank Account Balance Information">
<thread>
<tr>
<th>Account Number</th>
<th>Account Balance</th>
</tr>
</thead>
<tbody>
<php?
/*Accounts*/
$currentMember->connection = $conn;
这是我得到错误行72的地方:
$accounts = $currentMember->retrieve_all_accounts();
/* Loop Though Accounts*/
while($account = mysqli_fetch_assoc($account)) {
/* Retrieve Account Balance*/
$bankaccount = new Bankaccount ($account['BankAccountID']);
$bankaccount->connection = $conn;
$balance = mysqli_fetch_assoc($bankaccount->retrieve_current_balance());
echo '<tr>' . "\n";
echo "\t" . '<td class="account_number">' . $account['BankAccountID'] . '</td>' . "\n";
echo "\t" . '<td class="account_balance">$' . number_format($balance['CurrentBalance'], 2) . '</td>' . "\n";
echo '</tr>' . "\n";
}
/*Closed DataBase*/
mysqli_close($db->connection);
?>
答案 0 :(得分:0)
首先,您在第一部分代码中使用了这个:
<php?
/*Accounts*/
$currentMember->connection = $conn;
如果您真的复制粘贴了这个,那么这里有一个问题:这不是PHP代码。
相反,你应该:
<?php
/*Accounts*/
$currentMember->connection = $conn;
请注意,PHP开头标记为<?php
而不是<php?
然后,您的$currentMember
变量以这种方式设置:
$currentMember =unserialize($_session['currentMember']);
这似乎只会在容器上生成$currentMember
,而不是具有retrieve_all_accounts()
方法的类的实例。
因此,在尝试调用该方法时:
$accounts = $currentMember->retrieve_all_accounts();
您收到致命错误,因为$currentMember
对象中没有此类方法。