我收到錯誤消息:嘗試獲取非對象的屬性 當我嘗試從數據庫顯示滑塊時。試圖獲取非對象屬性(Codeigniter)
消息:試圖讓非對象的屬性 文件名:家用/ index.php的 行號:78
從管理方面,管理進入滑塊名稱,圖像和描述,並 它將在主頁
顯示在用戶端在本地主機(使用WAMP)這是工作完美,但是當我將在網上上傳,這是給錯誤
Home.php(控制器的文件)
if (! defined('BASEPATH'))
exit('No direct script access allowed');
class Home extends CI_Controller
{
public function index()
{
$this->load->view('home/index');
}
}
的index.php(查看文件)
<div class="body_resize">
<div class="body">
<div class="border_box">
<div class="box_skitter box_skitter_large">
<?php
$info=$this->dbcommon->getInfo(array('homepage_image'),'homepage',array('status'=>0),'1','','sort_order');
foreach($info as $row)
{
print_r($row);
?>
<ul>
<li>
<img src="<?php echo homepage.'medium/'.$row->homepage_image ?>" class="cubeHide" alt="8_abs.jpg"
width="900" height="400" />
</li>
</ul>
<?php
}?>
</div>
</div>
<script src="js/jquery.skitter.js" type="text/javascript" defer="defer"></script>
<script type="text/javascript" defer="defer">
$(document).ready(function() {
var options = {};
if (document.location.search) {
var array = document.location.search.split('=');
var param = array[0].replace('?', '');
var value = array[1];
if (param == 'animation') {
options.animation = value;
}
else if (param == 'type_navigation') {
if (value == 'dots_preview') {
$('.border_box').css({ 'marginBottom': '40px' });
options['dots'] = true;
options['preview'] = false;
}
else {
options[value] = true;
if (value == 'dots') $('.border_box').css({ 'marginBottom': '40px' });
}
}
}
$('.box_skitter_large').skitter(options);
});
</script>
<div class="body_home">
<h4><strong>Welcome to Softloopers!</strong></h4>
<?php $info=$this->dbcommon->getInfo('','master','','','0,1','');
echo $info->homepage;
?><br />
</div>
的getInfo功能
function getInfo($field_name='',$table_name,$array='',$return="",$limit='',$orderby='')
{
if($field_name=='')
{
$sql='select * ';
}
else
{
$str='';
foreach($field_name as $row)
{
$str.=$row.',';
}
$str=rtrim($str,',');
$sql="select ".$str;
}
$sql.= ' from ' .$table_name .' where 2>0 ';
if($array!='')
{
foreach($array as $key=>$value)
{
$sql.="and $key='$value' and";
}
$sql=trim($sql,' and');
}
if($orderby!='')
{
$sql.=" order by $orderby";
}
if($limit!='')
{
$sql.=" limit $limit";
}
$query = $this->db->query($sql);
if($return=='')
{
return $query->row();
}
else
{
return $query->result();
}
}
其中此'的getInfo function'限定?? –
您無法在視圖中編寫代碼。使用控制器來做到這一點 –