请帮助我死路检查我的图片在视图中的codeigniter消息错误类别开放 enter image description here
但是对于类别结束和所有完成的工作没有错误; 请帮忙
控制器
$limits=5;
$xx=$this->db->query('select * from posting')->row_array();
$x=$this->db->query('select * from kategori')->row_array();
in_array($x['kategori'],$dataArray=unserialize($xx['kategori'])) ? $x['kategori'] : '' ;
foreach ($dataArray as $keys => $value) {
if (($value == $link)) {
$data['view']=$this->Cek_level->view6($limits,$link)->result();
}
}
在视图中
<?php foreach($view as $row){?>
答案 0 :(得分:1)
您的代码只是做了很多假设,好像变量总是被设置并且是正确的类型。
$limits=5;
// First query
$xx = $this->db->query('select * from posting');
// Make sure you have a row before you try to use it.
if( $xx->num_rows() == 1 )
{
$y = $xx->row_array();
// Unserialize can always fail
$dataArray = @unserialize( $y['kategori'] );
}
// Second query
$x = $this->db->query('select * from kategori');
// Make sure you have a row before you try to use it.
if( $x->num_rows() == 1 )
{
$z = $x->row_array();
}
/*
It's impossible for me to know what you are trying to do here
in_array( $y['kategori'], $dataArray )
? $z['kategori']
: '' ;
*/
// Make sure that dataArray is available as an array
if( isset( $dataArray) && is_array( $dataArray ) )
{
foreach( $dataArray as $keys => $value )
{
// Make sure that $link exists
if( isset( $link ) && $value == $link )
{
$data['view'] = $this->Cek_level->view6( $limits, $link )->result(); // Why not pass back the result ??
}
}
}
// Here we make sure view is available, no matter what happened
if( ! isset( $data['view'] ) )
$data['view'] = [];
此代码显然未经过测试,需要您进行更改才能使其正常工作,但会显示您需要检查数据和变量是否存在。