注意:未定义的属性:C:\wamp\www\social\includes\class-query.php 中的 stdClass::$user_id 第 134 行 [英] Notice: Undefined property: stdClass::$user_id in C:\wamp\www\social\includes\class-query.php on line 134
问题描述
我每次尝试查看我的时间提要时都会出现此错误.我不知道代码有什么问题.有人可以帮忙吗?我的代码如下.将首先添加第 134 行,然后添加其余代码
公共函数 do_news_feed($user_id) {$status_objects = $this->get_status_objects($user_id);foreach ( $status_objects as $status ) {?><div class="status_item">第 134 行 -----><?php $user = $this->load_user_object($status->user_id);?><h3><a href="/social/profile-view.php?uid=<?php echo $user->ID; ?>"><?php echo $user->user_nicename;?></a></h3><p><?php echo $status->status_content;?></p>
<?php}}
完整代码
select($query);如果(!$obj){返回未找到用户";}返回 $obj[0];}公共函数 load_all_user_objects() {全球 $db;$table = 's_users';$查询 = "SELECT * FROM $table";$obj = $db->select($query);如果(!$obj){返回未找到用户";}返回 $obj;}公共函数 get_friends($user_id) {全球 $db;$table = 's_friends';$查询 = "SELECT ID,friend_id FROM $tableWHERE user_id = '$user_id'";$friends = $db->select($query);foreach ( $friends 作为 $friend ) {$friend_ids[] = $friend->friend_id;}返回 $friend_ids;}公共函数 get_status_objects($user_id) {全球 $db;$table = 's_status';$friend_ids = $this->get_friends($user_id);如果(!空($friend_ids)){array_push($friend_ids, $user_id);} 别的 {$friend_ids = array($user_id);}$accepted_ids = implode(', ', $friend_ids);$查询 = "SELECT * FROM $tableWHERE user_id IN ($accepted_ids)ORDER BY status_time DESC";$status_objects = $db->select($query);返回 $status_objects;}公共函数 get_message_objects($user_id) {全球 $db;$table = 's_messages';$查询 = "SELECT * FROM $tableWHERE message_recipient_id = '$user_id'";$messages = $db->select($query);返回 $messages;}公共函数 do_user_directory() {$users = $this->load_all_user_objects();foreach ( $users as $user ) { ?><div class="directory_item"><h3><a href="/social/profile-view.php?uid=<?php echo $user->ID; ?>"><?php echo $user->user_nicename;?></a></h3><p><?php echo $user->user_email;?></p>
<?php}}公共函数 do_friends_list($friends_array) {foreach ( $friends_array 作为 $friend_id ) {$users[] = $this->load_user_object($friend_id);}foreach ( $users as $user ) { ?><div class="directory_item"><h3><a href="/social/profile-view.php?uid=<?php echo $user->ID; ?>"><?php echo $user->user_nicename;?></a></h3><p><?php echo $user->user_email;?></p>
<?php}}公共函数 do_news_feed($user_id) {$status_objects = $this->get_status_objects($user_id);foreach ( $status_objects as $status ) {?><div class="status_item"><?php $user = $this->load_user_object($status->user_id);?><h3><a href="/social/profile-view.php?uid=<?php echo $user->ID; ?>"><?php echo $user->user_nicename;?></a></h3><p><?php echo $status->status_content;?></p>