Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My hosting provider has moved my PHP site over to a new server and believe the PHP version is current 7.x, however my site is v 5.6. I have no idea how to fix this.

I am receiving this error:

A PHP Error was encountered

Severity: Warning

Message: Illegal string offset 'posts'

Filename: controllers/Blog.php

Line Number: 13

Here is the code 'posts'

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

    $this->data = '';
    $this->load->model('blog_model');
    $this->data['posts'] =  this->blog_model->get_all_blogs_and_posts('3');
}


If anyone has any suggestions would greatly appreciate the guidance...

What I have tried:

Not sure where to start, tried data['posts']= [];
but didn't work....
Posted
Updated 18-Jun-19 21:02pm

1 solution

Quote:
The code is valid, but it expects the function parameter $inputs to be an array. The "Illegal string offset" warning when using $inputs['type'] means that the function is being passed a string instead of an array.
You have declared $this->data = ''; which is a string, not an array.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900