首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHP BD错误行72

PHP BD错误行72
EN

Stack Overflow用户
提问于 2011-04-16 23:26:46
回答 1查看 116关注 0票数 0

错误是致命错误:在第72行的/home/mjcrawle/public_html/cit0215/assignment5/onlinebanking/viewaccounts.php中调用未定义的方法stdClass::retrieve_all_accounts()

我没有得到任何html错误,所以我将忽略这一点。

我的php代码直到这个错误是:

代码语言:javascript
复制
<?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">&nbsp;</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的地方:

代码语言:javascript
复制
$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);

?>
EN

回答 1

Stack Overflow用户

发布于 2011-04-16 23:32:57

首先,您在第一部分代码中使用了以下内容:

代码语言:javascript
复制
<php?
/*Accounts*/
$currentMember->connection = $conn;

如果您真的复制粘贴了这段代码,那么这里就有一个问题:这不是PHP代码。

相反,你应该拥有:

代码语言:javascript
复制
<?php
/*Accounts*/
$currentMember->connection = $conn;

请注意,PHP开始标记是<?php而不是<php?

然后,这样设置您的$currentMember变量:

代码语言:javascript
复制
$currentMember =unserialize($_session['currentMember']);

这似乎使得$currentMember只存在于容器上,而不是具有retrieve_all_accounts()方法的类的实例。

因此,当尝试调用该方法时:

代码语言:javascript
复制
$accounts = $currentMember->retrieve_all_accounts();

您会得到一个致命错误,因为您的$currentMember对象中没有这样的方法。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5687507

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档