Недопустимое смещение строки в codeigniter

0

Я использую codeigniter для разработки системы управления собственностью. Я получаю ошибочную ошибку смещения для каждого $ data [''], определенного в функции контроллера. Другие функции в одном контроллере прекрасно работают без каких-либо проблем. Я попробовал exisitng ответы, предоставленные для ошибки "незаконное offest", но никто из них не ответил на мою проблему. Вот мой код: -

Модель (model_season.php): -

            function insertSeason($data){

            $season_flag = '';

            $this->db->insert("season",$data);


            if ($this->db->affected_rows()>0){

                    $season_flag = true;
           } else {

                    $season_flag = false;
           }

               return $season_flag;

         }




       function getAllSeason(){


        $this->db->select('*');
        $this->db->from('season');
        $this->db->join('property', 'property.PropertyID = season.SeasonID', 'inner');
        $this->db->order_by('season.SeasonID', 'DESC');

        //$this->db->from('season');
        //$this->db->order_by("SeasonID", "DESC");
        $query = $this->db->get();
        return $query->result();


        }

Вот контроллер (season.php): -

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Season extends CI_Controller{



    function __construct(){

        parent::__construct();
        $this->load->model('model_season');
        $this->load->model('model_property');
        $this->load->model('user');


     }


     function index(){

            if ($this->session->userdata('logged_in'))
            {
                $this->load->helper(array('form'));

                $this->lang->load('common');
                $this->lang->load('season');

                $session_data = $this->session->userdata('logged_in');
                $data['user_name']          = $session_data['user_name'];
                $data['property_list']      = $this->model_property->GetAllProperty();
                $data['season_list']        = $this->model_season->getAllSeason();


                $this->load->view('backend/header');
                $this->load->view('backend/add_season_view',$data);
                $this->load->view('backend/footer');


            } else {

                redirect('login', 'refresh');
            }
     }





      function navigateToSeason($data_){



            if ($this->session->userdata('logged_in'))
            {





                $this->load->helper(array('form'));

                $this->lang->load('common');
                $this->lang->load('season');

                $session_data = $this->session->userdata('logged_in');
                $data['user_name']          = $session_data['user_name'];
                $data['property_list']      = $this->model_property->GetAllProperty();
                //var_dump($this->model_season->getAllSeason());
                $data['season_list']        = $this->model_season->getAllSeason();

                if ($data_ == 1){
                $data['message'] = "success";
                }
                if ($data_ == 0){
                        $data['message'] = "error..";
                }


                $this->load->view('backend/header');
                $this->load->view('backend/add_season_view',$data);
                $this->load->view('backend/footer');


            } else {

                redirect('login', 'refresh');
            }
     }

     function addSeason(){

                echo 'function test pass..';


                $username = $this->input->post('username');

                $this->load->library('form_validation');

                $validaton_options = array (

                            array(

                                        'field' => 'season_selected_property',
                                        'label' => 'Property',
                                        'rules' => 'trim|numeric|required|xss_clean'
                                ),



                            array(

                                        'field' => 'season_title',
                                        'label' => 'Season Title',
                                        'rules' => 'trim|required|xss_clean'
                                ),



                            array(

                                        'field' => 'season_start_date',
                                        'label' => 'Season start date',
                                        'rules' => 'trim|required|callback_date_valid'
                                ),



                            array(

                                        'field' => 'season_end_date',
                                        'label' => 'Season end date',
                                        'rules' => 'trim|required|callback_date_valid'
                                )
                    );


                    $this->form_validation->set_rules($validaton_options);


                    //start form validation
                    if ($this->form_validation->run() == true){


                                $NewSeason = array(

                                        "SeasonPropertyID"=> $this->input->post('season_selected_property'),
                                        "SeasonTitle"=>$this->input->post('season_title'),
                                        "StartDate"=>$this->input->post('season_start_date'),
                                        "EndDate"=>$this->input->post('season_end_date')


                                );


                                //check - add to database
                                if ($this->model_season->insertSeason($NewSeason)){     

                                        redirect('season/navigateToSeason/1','refresh');


                                } else {

                                        redirect('season/navigateToSeason/0','refresh');

                                }
                                // end database add






                    } else {


                                            if ($this->session->userdata('logged_in'))
                                            {
                                                $this->load->helper(array('form'));

                                                $this->lang->load('common');
                                                $this->lang->load('season');

                                                $session_data = $this->session->userdata('logged_in');
                                                $data['user_name'] = $session_data['user_name'];
                                                $data['property_list']      = $this->model_property->GetAllProperty();
                                                $data['season_list']        = $this->model_season->getAllSeason();


                                                $this->load->view('backend/header');
                                                $this->load->view('backend/add_season_view',$data);
                                                $this->load->view('backend/footer');


                                            } else {

                                                redirect('login', 'refresh');
                                            }

                    }
                    //end form validation


     }//end function



     public function date_valid($date)
    {
            $parts = explode("-", $date);
            if (count($parts) == 3) {      
                    if (checkdate($parts[1], $parts[2], $parts[0]))
                    {
                        return TRUE;
                    }
            }

            $this->form_validation->set_message('date_valid', 'The Date field must be yyyy-mm-dd');

            return false;
    }









}


?>

Вот мое мнение: -

  <?php if (isset($message)  && $message != ''){

                echo  $message;
            }


       if (isset($user_name) && $user_name != ''){
                  echo $user_name;
       }




         if (isset($season_list))
         {  


                       foreach ($season_list as $season){


                                        echo $season->SeasonTitle; 
                                        echo $season->StartDate; 
                                        echo $season->EndDate; 
                       }


          }

 ?>

Это мои ошибки:

Возникла ошибка PHP

Уровень важности: предупреждение

Сообщение: Недопустимое смещение строки 'user_name'

Имя файла: controllers/season.php

Номер строки: 65

Возникла ошибка PHP

Уровень важности: предупреждение

Сообщение: Недопустимое смещение строки 'property_list'

Имя файла: controllers/season.php

Номер строки: 66

Возникла ошибка PHP

Уровень важности: уведомление

Message: Преобразование массива в строку

Имя файла: controllers/season.php

Номер строки: 66

Возникла ошибка PHP

Уровень важности: предупреждение

Сообщение: Недопустимое смещение строки 'message'

Имя файла: controllers/season.php

Номер строки: 70 "

Var Dumb Result - var_dump ($this-> model_season-> getAllSeason()):

 array(2) { [0]=> object(stdClass)#42 (29) { ["SeasonID"]=> string(1) "2" ["SeasonPropertyID"]=> string(2) "14" ["SeasonTitle"]=> string(6) "ghfghf" ["StartDate"]=> string(10) "2014-11-24" ["EndDate"]=> string(10) "2014-11-30" ["PropertyID"]=> string(1) "2" ["Title"]=> string(16) "Hill Apartment" ["Description"]=> string(562) "In March 2014, Nayon “ †Fonseka, re-established Lake House, a 13-room Bed & Breakfast / Budget Hotel, that has been owned by her family for 40 years. Down a quiet residential lane in the heart of commercial city, Lake House was one of the first accredited tourist accommodations in the Island, which   refurbished with her usual creative flair. Conceived as a ‘home away from home†while in the Island, whether for a few days of holiday or a month on business, Lake House is ideally located and run in an unobtrusive, yet professional manner." ["StarRating"]=> string(1) "4" ["GoogleMapURL"]=> string(25) "https://goo.gl/maps/xKwPQ" ["Address"]=> string(20) "alvo Terrace, Kandy" ["Telephone"]=> string(11) "94112326443" ["Fax"]=> string(11) "94112326443" ["TripAdvisorURL"]=> string(116) "http://www.tripadvisor.com/Hotel_Review-g293962-d586475-Reviews- _Villas_Lake_Lodge-city_Western_Province.html" ["ThumbNail1"]=> string(6) "DD.jpg" ["ThumbNail2"]=> string(0) "" ["ThumbNail3"]=> string(0) "" ["WebSiteURL"]=> string(18) "www. villas.com" ["Email"]=> string(24) "lakelodge@ villas.com" ["TaxChargesPercentage"]=> string(1) "2" ["TaxDescription"]=> string(60) "This includes service charges and the Island Government taxes" ["Enabled"]=> string(1) "1" ["DateCreated"]=> string(10) "2014-10-31" ["CreatedBy"]=> string(8) " vila" ["LastModified"]=> string(10) "2014-11-05" ["ModifiedBy"]=> string(8) " vila" ["ExtraBedPrice"]=> string(3) "120" ["Direction"]=> string(477) "Lake House is situated down alvo terrace off alvo place. You have to access it through Perehera Mawatha, which is off Sir James Pieris Mawatha (this is the road going towards the Nawaloka hospital). On Perahera Mawatha, passing Bishopâ€s College auditorium is a playground, you take the first turn on to your left after you pass the playground, which is alvo Place. Down alvo Place the first turn to your left is alvo terrace, the hotel is right at the bottom of the lane" ["ExtraBed"]=> string(1) "0" } [1]=> object(stdClass)#41 (29) { ["SeasonID"]=> string(1) "1" ["SeasonPropertyID"]=> string(2) "25" ["SeasonTitle"]=> string(10) "Off Season" ["StartDate"]=> string(10) "2014-11-10" ["EndDate"]=> string(10) "2014-11-24" ["PropertyID"]=> string(1) "1" ["Title"]=> string(8) "DD Lodge" ["Description"]=> string(562) "In March 2014, Nayon “ †Fonseka, re-established Lake House, a 13-room Bed & Breakfast / Budget Hotel, that has been owned by her family for 40 years. Down a quiet residential lane in the heart of commercial city, Lake House was one of the first accredited tourist accommodations in the Island, which   refurbished with her usual creative flair. Conceived as a ‘home away from home†while in the Island, whether for a few days of holiday or a month on business, Lake House is ideally located and run in an unobtrusive, yet professional manner." ["StarRating"]=> string(1) "3" ["GoogleMapURL"]=> string(25) "https://goo.gl/maps/xKwPQ" ["Address"]=> string(30) "alvo Terrace, city 3 00300" ["Telephone"]=> string(11) "94112326443" ["Fax"]=> string(11) "94112326443" ["TripAdvisorURL"]=> string(116) "http://www.tripadvisor.com/Hotel_Review-g293962-d586475-Reviews- _Villas_Lake_Lodge-city_Western_Province.html" ["ThumbNail1"]=> string(7) "LL1.jpg" ["ThumbNail2"]=> string(1) "0" ["ThumbNail3"]=> string(1) "0" ["WebSiteURL"]=> string(18) "www. villas.com" ["Email"]=> string(24) "lakelodge@ villas.com" ["TaxChargesPercentage"]=> string(1) "2" ["TaxDescription"]=> string(60) "This includes service charges and the Island Government taxes" ["Enabled"]=> string(1) "1" ["DateCreated"]=> string(10) "0000-00-00" ["CreatedBy"]=> string(0) "" ["LastModified"]=> string(10) "0000-00-00" ["ModifiedBy"]=> string(0) "" ["ExtraBedPrice"]=> string(1) "0" ["Direction"]=> string(477) "Lake House is situated down alvo terrace off alvo place. You have to access it through Perehera Mawatha, which is off Sir James Pieris Mawatha (this is the road going towards the Nawaloka hospital). On Perahera Mawatha, passing Bishopâ€s College auditorium is a playground, you take the first turn on to your left after you pass the playground, which is alvo Place. Down alvo Place the first turn to your left is alvo terrace, the hotel is right at the bottom of the lane" ["ExtraBed"]=> string(1) "0" } }
Теги:
codeigniter
codeigniter-2

1 ответ

0
Лучший ответ

Задача решена. Проблема была параметром в функции navigateToSeason ($ data) в моем контроллере. Я переименовал perameter $ data в $ data_, и теперь он работает плавно. Обязательно выберите другое имя параметра для каждой функции.

Ещё вопросы

Сообщество Overcoder
Наверх
Меню