Welcome Guest, Not a member yet? Register   Sign In
Array To String error / undefined $query
#15

Code:
A PHP Error was encountered

Severity: Notice

Message: Array to string conversion

Filename: core/MY_Controller.php

Line Number: 24

Backtrace:

File: /home/codmol/public_html/siiga/application/core/MY_Controller.php
Line: 24
Function: _error_handler

File: /home/codmol/public_html/siiga/application/core/MY_Controller.php
Line: 45
Function: render

File: /home/codmol/public_html/siiga/application/controllers/admin/Docs.php
Line: 73
Function: render

File: /home/codmol/public_html/siiga/index.php
Line: 315
Function: require_once
An Error Was Encountered

Unable to load the requested file: templates/Array_view.php
This is the error.


MY_Controller

Code:
<?php defined('BASEPATH') OR exit('No direct script access allowed');

class MY_Controller extends CI_Controller
{
 protected $data = array();
 function __construct()
 {
   parent::__construct();
   $this->data['page_title'] = 'SIIGA';
   $this->data['before_head'] = '';
   $this->data['before_body'] ='';
 }

 protected function render($the_view = NULL, $template = 'siiga_admin')
 {
   if($template == 'json' || $this->input->is_ajax_request())
   {
     header('Content-Type: application/json');
     echo json_encode($this->data);
   }
   else
   {
     $this->data['the_view_content'] = (is_null($the_view)) ? '' : $this->load->view($the_view,$this->data, TRUE);;
     $this->load->view('templates/'.$template.'_view', $this->data);
   }
 }
}

class Admin_Controller extends MY_Controller
{

 function __construct()
 {
   parent::__construct();
   $this->load->library('ion_auth');
   if (!$this->ion_auth->logged_in())
   {
     redirect('admin/user/login', 'refresh');
   }
   $this->data['page_title'] = 'SIIGA';
 }

 protected function render($the_view = NULL, $template = 'siiga_admin')
 {
   parent::render($the_view, $template);
 }
}

class Public_Controller extends MY_Controller
{

 function __construct()
 {
   parent::__construct();
 }
}

Controller

Code:
 public function existing() // Recieved, Unsolved
 {
     $this->load->database();
     $this->load->model('Docs_model');
     $this->load->library('table');
     $this->data['query'] = $this->Docs_model->viewexisting();

     $this->render('admin/docs/existing_view', $this->data);
 }
View
Code:
<table>
<?php foreach($query as $row){?>
   <tr>
       <td><?php echo $row->numar_inreg ;?></td>
       <td><?php echo $row->nume_doc ;?></td>
   </tr>
<?php }?>
</table>
I changed $data to $this->data, should've fixed things but it didn't.
Reply


Messages In This Thread
RE: Array To String error / undefined $query - by CodinMoldovanu - 08-18-2016, 03:26 PM



Theme © iAndrew 2016 - Forum software by © MyBB