错误是致命错误:在第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);
?>发布于 2011-04-16 23:32:57
首先,您在第一部分代码中使用了以下内容:
<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对象中没有这样的方法。
https://stackoverflow.com/questions/5687507
复制相似问题