简体   繁体   English

代码点火器:遇到PHP错误严重性:注意消息:未定义的变量:页面文件名:admin / display_page.php行号:18

[英]Code Igniter: A PHP Error was encountered Severity: Notice Message: Undefined variable: page Filename: admin/display_page.php Line Number: 18

I'm getting the following error inside the admin page where I can view the table containing all the pages: 我在管理页面内看到以下错误,我可以在其中查看包含所有页面的表:

A PHP Error was encountered Severity: Notice 遇到PHP错误严重性:注意

Message: Undefined variable: page 消息:未定义的变量:页面

Filename: admin/display_page.php 文件名:admin / display_page.php

Line Number: 18 行号:18

Any idea what I should change? 知道我应该改变什么吗? the code inside display_page.php is similar to the display_news.php but for some reason, the backend page related to the pages shows an error and the one for the news is working fine. display_page.php中的代码与display_news.php类似,但是由于某些原因,与页面相关的后端页面显示错误,并且该新闻页面工作正常。

That's the code inside display_page.php: 那是display_page.php中的代码:

<form name="listing" id="listing" action="<?php echo base_url(); ?>admin/page/delete" method="post">

<input name="lang" type="hidden" value="<?php echo $lang;?>" />

<table width="900" border="0" cellspacing="0" cellpadding="0" class="listingTbl">
  <tr>

    <th width="100">Page Id</th>
      <th>Page Title</th>
    <th width="150"><a class="filter-column" href="?sort=page_group">Page Group</a></th>
    <th width="100">Actions</th>
  </tr>
  <?
  foreach($page_s as  $page){?>
  <tr>

    <td><?php echo $page["page_id"];?>&nbsp;</td>
    <td><?php echo $page["page_title"];?>&nbsp;</td>
    <td><?php echo $page["page_group"];?>&nbsp;</td>
    <td>
    <a href="<?php echo base_url(); ?>admin/page/action/<?php echo $page["lang"];?>/<?php echo $page["page_id"];?>">
    <img src="<?php echo base_url(); ?>admin_images/edit.png" width="16" height="16" />
    </a>
    </td>
  </tr>
  <? }?>
</table>
</form>

<div id="delete-block"><a href="#" id="delete-items"><img src="<?php echo base_url(); ?>admin_images/drop.png" width="16" height="16" align="absmiddle" > Delete Checked Items</a></div>
<div id="pagination-block">Go to <?php echo $this->pagination->create_drop_down();?></div>

EDIT: 编辑:

That's the code related to the pages in the controller file: 那是与控制器文件中的页面相关的代码:

function index()
{

    $sort = isset($_GET['sort']) ? $_GET['sort'] : null;

    $lang = ( isset($this->uri_arr["lang"]) ) ? $this->uri_arr["lang"] : "en";

    ///////////////////////////////////////////////////////////

    $current_page = (isset($this->uri_arr["page"])) ? $this->uri_arr["page"] : 1 ;
    $per_page = "20";
    $offset =  ($current_page-1) * $per_page;

    $config["base_url"] = base_url()."admin/page/index/";
    $config["total_rows"] = $this->Page_model->num_page_s(array( "lang" => $lang ));
    $config['per_page'] = '20';
    $this->pagination->initialize($config);

    ///////////////////////////////////////////////////////////
    $order_by = (isset($sort) && $sort == 'page_group') ? 'page_group ASC' : null;

    $pages = $this->Page_model->get_all_page_s( $per_page , $offset , $lang, $order_by );

    $this->load->vars( array( "page_s" => $pages, "lang" => $lang ));

    $this->data["main_content"] = $this->load->view( "admin/display_page" , "" , TRUE );

    $this->load->view( 'admin/template' , $this->data );

}

My guess is you don't have short_open_tag enabled and so this line :- 我的猜测是您没有启用short_open_tag ,所以这一行:-

<? foreach($page_s as $page){?>

isn't working. 不起作用。 You would need to change it to this:- 您需要将其更改为:-

<?php foreach($page_s as $page){ ?>

add this line to your controller when loading view pass $data variable to view. 在加载视图时将此行添加到您的控制器,并传递$data变量到视图。

$data['page_s']=$your_array;
$this->load->view('file_path/file_name',$data);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 遇到PHP错误严重性:通知消息:未定义的属性:CI_Loader :: $ p文件名:Templates / public.php行号:24 - A PHP Error was encountered Severity: Notice Message: Undefined property: CI_Loader::$p Filename: Templates/public.php Line Number: 24 遇到PHP错误严重性:通知消息:未定义的属性:stdClass :: $ file文件名:controllers / arsip.php行号:137 - A PHP Error was encountered Severity: Notice Message: Undefined property: stdClass::$file Filename: controllers/arsip.php Line Number: 137 遇到PHP错误严重性:通知消息:未定义的属性:Social :: $ social_model文件名:controllers / social.php行号:10 - A PHP Error was encountered Severity: Notice Message: Undefined property: Social::$social_model Filename: controllers/social.php Line Number: 10 遇到 PHP 错误严重性:通知消息:未定义的属性:stdClass::$comment_count 文件名:blog/index.php 行号:35 - A PHP Error was encountered Severity: Notice Message: Undefined property: stdClass::$comment_count Filename: blog/index.php Line Number: 35 遇到 PHP 错误严重性:通知消息:未定义变量:结果 - A PHP Error was encountered Severity: Notice Message: Undefined variable: result 遇到 PHP 错误严重性:警告消息:为 foreach() 提供的参数无效文件名:views/page_view.php 行号:13 - A PHP Error was encountered Severity: Warning Message: Invalid argument supplied for foreach() Filename: views/page_view.php Line Number: 13 遇到 PHP 错误严重性:注意消息:试图获取非对象的属性文件名:blog/index.php 行号:23 - A PHP Error was encountered Severity: Notice Message: Trying to get property of non-object Filename: blog/index.php Line Number: 23 遇到PHP错误严重性:通知消息:未定义的属性:stdClass :: $ abbrev - A PHP Error was encountered Severity: Notice Message: Undefined property: stdClass::$abbrev 遇到 PHP 错误严重性:通知消息:未定义索引:问题 - A PHP Error was encountered Severity: Notice Message: Undefined index: questions 遇到PHP错误严重性:通知消息:未定义的偏移量:0 - A PHP Error was encountered Severity: Notice Message: Undefined offset: 0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM