[英]Trying to get property of non-object the error focuses on <td>'.$users->username.'</td>
I'm having this error please can anyone help?我遇到了这个错误,有人可以帮忙吗?
Trying to get property of non-object the error focuses on
<td>'.$users->username.'</td>
试图获取非对象的属性,错误集中在
<td>'.$users->username.'</td>
Below is my code that has an error:下面是我有错误的代码:
function GetactivationReq()
{
$settings = DB::table('settings')->where('id', 1)->first();
$users = DB::table('activationFee')->orderBy('id', 'desc')->get();
foreach ($users as $row) {
$users = DB::table('users')->where('id', $row->sender_id)->first();
$receiver = DB::table('users')->where('id', $row->receiver_id)->first();
$user = DB::table('userdetails')->where('userid', $row->sender_id)->first();
echo '<tr>
<th><input type="checkbox" class="select-all" value="1"></th>
<td>'.$users->username.'</td>
<td>'.$user->accountname.'</td>
<td>'.$receiver->username.'</td>
<td>'.$settings->currency.''.$row->amount.'</td>
<td>'.$row->payment_status.'</td>
</tr>';
}
}
I Think this code will help you i dont know the username field is exiest in which table so i will give the both options : may b this will works for you :我认为这段代码会帮助你我不知道用户名字段在哪个表中是最有效的,所以我会给出两个选项:也许这对你有用:
function GetactivationReq()
{
$settings = DB::table('settings')->where('id', 1)->first();
$users = DB::table('activationFee')->orderBy('id', 'desc')->get();
foreach ($users as $row) {
$users_new = DB::table('users')->where('id', $row->sender_id)->first();
$receiver = DB::table('users')->where('id', $row->receiver_id)->first();
$user = DB::table('userdetails')->where('userid', $row->sender_id)->first();
echo '<tr>
<th><input type="checkbox" class="select-all" value="1"></th>
<td>'.@$users->username.'</td>
<td>'.@$users_new->username.'</td>
<td>'.$user->accountname.'</td>
<td>'.$receiver->username.'</td>
<td>'.$settings->currency.''.$row->amount.'</td>
<td>'.$row->payment_status.'</td>';
}
}
The code makes no sense but maybe this one can help:代码没有意义,但也许这个可以帮助:
function GetactivationReq()
{
$settings = DB::table('settings')->where('id', 1)->first();
$activationFees = DB::table('activationFee')->orderBy('id', 'desc')->get();
foreach ($activationFees as $row) {
$user = DB::table('users')->where('id', $row->sender_id)->first();
$receiver = DB::table('users')->where('id', $row->receiver_id)->first();
$userDetail = DB::table('userdetails')->where('userid', $row->sender_id)->first();
echo '<tr>
<th><input type="checkbox" class="select-all" value="1"></th>
<td>' . $user->username . '</td>
<td>' . $userDetail->accountname . '</td>
<td>' . $receiver->username . '</td>
<td>' . $settings->currency . '' . $row->amount . '</td>
<td>' . $row->payment_status . '</td>';
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.