So, it is solved now :) This problem happened twice in two files: First is which stated in my question, and I had an error in another query at the same page. Second problem was in the HTML file. My complete view was like this:
<?php if(isset($service) && count($service) > 0){ ?>
<div class="row job-detail-row">
<div class="col-lg-6 job-detail-label"><?php echo lang('contractType'); ?></div>
<div class="col-lg-6"><a href=""><?php if(isset($service->contractType)) echo $service->contractType; ?></a></div>
</div>
<?php } ?>
<ul>
<?php foreach ($similarServices as $service) { ?> <<========= NOTICE: $service here is the same as the above condition
<li>
<div class="title"><a href="<?php echo site_url('services/service/'.$service->id) ?>"><?php echo $service->title; ?></a>
</div>
</li>
<?php }//end foreach similarServices ?>
</ul>
It appeared because i used the same variable name $service
, so i changed it and it works now. Hope this helps you.