简体   繁体   中英

PHP error code: Notice: Trying to get property … of non-object in C:\xampp\htdocs\testing\index3.php on line 95

I tried to work on the following script;

<?php


if ($result = $mysqli->query($query)) {
    while ($row = $result->fetch_assoc()) {
        $id = $row["id"];
        $fullname = $row["fullname"];
        $biography = $row["biography"];
        $email = $row["email"];
        $facebook = $row["facebook"];   
        $twitter = $row["twitter"];
        $gplus = $row["gplus"];
        $linkedin = $row["linkedin"];
      
   
 
echo    '<div id="tabs-'.$row['id'].'" aria-labelledby="ui-id-'.$row['id'].'" role="tabpanel" class="ui-tabs-panel ui-corner-bottom ui-widget-content" aria-hidden="true" style="display: none;"><p>'.$row['biography'].'</p>


<div class="icon-bar">

<p>';



if ($view->$linkedin=='') {
    # code...
    $view = '';
}else{
    $view = '<a href="'.$row[linkedin].'" class="facebook"><i class="fa fa-linkedin"></i></a>';

}



echo
'
</p>
</div>
</div>';


    }
}

?>

but got the following error:

Notice: Trying to get property 'https://www.linkedin.com/in/data-analyst-project-management-cloud-expert-bigdata/' of non-object in C:\xampp\htdocs\testing\index3.php on line 95...

Can someone please help me out.

I don't see any view object that you have defined. If you have defined view object then also you code must be

if($view->linkedin == ''){
    //code
}

Or if you have not defined view object the code code may be

if($linkedin == ''){
    //code
}

I have been able to resolve the issue using

if ($linkedin=='') {
    # code...
    $view = '';
}else{
    echo '<a href="'.$row['linkedin'].'" class="facebook"><i class="fa fa-linkedin"></i></a>';

}

Thanks to @catcon,@Suresh Chand

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM