Welcome Guest, Not a member yet? Register   Sign In
Restored old site but new errors shown
#5

(This post was last modified: 09-08-2021, 05:53 AM by Inquisitor. Edit Reason: removed spacing )

(09-06-2021, 02:48 PM)includebeer Wrote: I’m pretty sure CI 2.x is only compatible with PHP 5.6 or lower. I would be surprised if it worked with PHP 7 or 8. Upgrading to CI 4 is mostly a rewrite of your website. But if you don’t want to do this a the moment, you can at least upgrade your website to CI 3.x and run it with PHP 7. There’s not a lot of breaking changes between version 2 and 3. I’m not sure if it will work with PHP 8. It’s an old version that don’t gets updated anymore. But it work well with PHP 7.

So I've done my upgrade. I read absolutely everything from the upgrade pages especially the 3.0 page: https://codeigniter.com/userguide3/insta...e_300.html
Nothing skipped or left out so I'm positive that I've done the upgrade correctly.

But I'm still getting the same problem where variables passed into the views cannot be seen. I'm not sure about the simplepie error, I might just remove that code for now, but I'm more interested in the menus.php problem and the error in core/Common.php:

Code:
A PHP Error was encountered

Severity: Warning

Message: Creating default object from empty value

Filename: libraries/Menus.php

Line Number: 36
...
Code:
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/seedeta1/public_html/ci3/system/core/Exceptions.php:271)

Filename: core/Common.php

Line Number: 570
...
Code:
An uncaught Exception was encountered

Type: ParseError

Message: syntax error, unexpected 'new' (T_NEW)

Filename: /home/seedeta1/public_html/ci3/application/libraries/Simplepie.php

Line Number: 738

Here is the beginning of my MY_Controller file:
PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
MY_Controller extends CI_Controller
{
 var 
$options;
 public function 
__construct()
 {
 
parent::__construct();
                require_once('application/libraries/Menus.php'); //Important, imported here.
                date_default_timezone_set('Europe/London');
 
 
$this->options->page_title='Home page';
 
 
$this->options->company $this->Company_model->get_company_details(array('c_id'=>1));//Get company details such as address / telephone plus jquery slider options.
 
}
....... 

So $options has been created and some properties applied. This code used to work fine.

The menus.php has been imported too.

It's still called CI_Controller in CI 3.0+ isn't it?

The menus file where I'm getting the error. Line 36 = the end of the file:

PHP Code:
<?php
//Contruct menu bar. This is used in includes/header.php
//Method = As in controller/method/id in CI urls.

$second_items=array( array('name'=>'Functional','method'=>'testing/functional'),
                    array('name'=>'Performance','method'=>'testing/performance'),
                    array('name'=>'Accessibility','method'=>'testing/accessibility'),
                    array('name'=>'Usability','method'=>'testing/usability'),
                    array('name'=>'Regression','method'=>'testing/regression'),
                    array('name'=>'Compatibility','method'=>'testing/compatibility') );

$sub_items=array( array('name'=>'Testing','method'=>'testing','sub_items'=>$second_items),
                  array('name'=>'Case Studies','method'=>'case_study'),
                  );

$services_menu = array('name'=>'Services','controller'=>'services','sub_items'=>$sub_items);

$sub_items=array( array('name'=>'Tools','method'=>'tools'),
                  array('name'=>'Cloud','method'=>'cloud'),
                  array('name'=>'Blog','method'=>'blog') );

$technology_menu = array('name'=>'Technology','controller'=>'technology','sub_items'=>$sub_items);

$sub_items=array( array('name'=>'About','method'=>'about'),
                  array('name'=>'Contact','method'=>'contact'),
                  array('name'=>'Careers','method'=>'careers'),
 
  array('name'=>'Team','method'=>'team') );
  
$company_menu 
=  array('name'=>'Company','controller'=>'company','sub_items'=>$sub_items); 

$this->options->menu_items= array($services_menu,$technology_menu,$company_menu);

$bullet_class=''
$sub_bullet_class=''

Now my main controller. This is where my processing starts when on the homepage. "var $options" is created here and passed into the view:
PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
Main extends MY_Controller
{
 var 
$options;
 public function 
__construct()
 {
 
parent::__construct();
    
 $this
->options->page_title='Home page';
 }
  
    
//Functions inherited from core/MY_Controller
    function email_sent() {parent::email_sent();}
    function password_reset_complete() {parent::password_reset_complete();}
 
 function 
index()
 {
        $this->load->model('Post_model');
        
        $this
->load->model('Images_model');
        $this->options->images $this->Images_model->get_images(array( 'page_id'=>));//Images for jquery slider, 1 for every feed.
          
 $this
->options->pages $this->Page_model->get_page( array('uri_name'=>'homepage') );
        
        $this
->load->model('Company_model');
        $this->options->company $this->Company_model->get_company_details();//Images for jquery slider, 1 for every feed.
        
        
//Load view.
 
$this->load->view('main/main_view',$this->options);
 }
}

/* End of file main.php */
/* Location: ./application/controllers/main.php */ 

So I'm not sure why menus.php can't see $options when it's created right before it in MY_Controller? Maybe it's some sort of scope issue. As mentioned it used to work fine before restoring the backup.

Now downgraded to PHP 7.4.22.
Reply


Messages In This Thread
RE: Restored old site but new errors shown - by Inquisitor - 09-08-2021, 03:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB