Problem with passing data to view in codeigniter code - php

I have a codeigniter code that is working on local Apache installation. But it does not work on Godaddy Hosting.
I have got other similar views and controllers which are working on Godaddy.
Following is the code. I have pasted only relevant code.
Controller:
function index() {
$this->load->model('Feedmodel');
$data['posts']=$this->Feedmodel->gethomedata();
$this->load->view('home',$data);
}
View:
PHP CODE ONLY
foreach($posts as $post){
echo $post['url'];
}
The error that I am getting is
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: posts
Filename: views/home.php
Line Number: 59
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/home.php
Line Number: 59
The same code is working fine with other controllers and views...

The reason that you are getting an error notice in the GoDaddy environment and not in your local installation is most probably because of different error reporting in the two php installations. Edit your local php.ini and index.php in the root codeigniter dir and verify that error_reporting(E_ALL); exists.
Also are you using the foreach loop to iterate through all the HTTP POST variables? if so try changing it to
foreach($_POST as $post){
echo $post;
}
you could also use codeigniter's input library to do this.
$post_url = $this->input->post('url');

Related

Can't get the default controller of codeigniter to work in IIS

I am trying to host a codeigniter project on IIS Server but I can't get even the default controller to show instead what I receive is this below
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_URI::$config is deprecated
Filename: core/URI.php
Line Number: 101
Backtrace:
File: C:\inetpub\wwwroot\app\index.php
Line: 315
Function: require_once
I have web.config file, HTTP mappings, ISAPI, URL rewrite module and FastCGI all set but still the problem persist.
I will be very grateful if you guys can help me, am stranded.

PHP scripts not working after migrating to PHP7

After migrating to PHP7.2 from PHP5.5 , my PHP scripts are not getting executed however phpinfo() is loading fine . I have installed php from source code .
I have enabled display_errors setting and it showing the following messages
[03-Oct-2018 16:32:12 UTC] PHP Warning: Creating default object from empty value in config.php on line 163
[03-Oct-2018 16:32:12 UTC] PHP Notice: Array to string conversion in get.php on line 25
[03-Oct-2018 16:32:12 UTC] PHP Notice: Undefined property: stdClass::$Array in get.php on line 25
But these are warnings and notices .
Am I missing some configuration to make the code work ?
On the first error in config.php file, you probably should instantiate a new stdClass() like the example below:
$var = new stdClass()
and then assign a value to its properties.
On the second error, you must have assigned the var as an array and then trying to echo that var
Without seeing the code I think its all the help I could give you

Troube with migrate an codeigniter system

I'm trying to migrate an codeigniter system for my localhost, but i'm receiving this message:
A PHP Error was encountered
Severity: Notice
Message: Only variable references should be returned by reference
Filename: core/Common.php
Line Number: 257
Fatal error: Class 'CI_Controller' not found in C:\xampp\htdocs\sistema-emisa\system\core\CodeIgniter.php on line 233
I've download the following pages from the host:
application ~
public_html ~
system
I changed the enters of the BD for the corrects on my localhost but still didnt work. I have to do some setting or download something else?
The server have this estructure:
One quick fix needs to be done.
Go to your system/core/Common.php file.
And search for return $_config[0] =& $config;
and replace this content with either of the following two snippets:
$_config[0] =& $config;
return $_config[0];
OR
return isset($_config[0][$item]) ? $_config[0][$item] : NULL;
Both of the above given pieces of codes will work.

CodeIgniter production deployment error 404

I finished my CodeIgniter application, managed to deploy it to shared hosting, but I'm getting error 404 and a warning.
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /data/web/virtuals/53627/virtual/www/application/config/config.php:1)
Filename: core/Common.php
Line Number: 568
Backtrace:
File: /data/web/virtuals/53627/virtual/www/index.php
Line: 292
Function: require_once
I've only had this issue since I switched to Codeigniter 3.0. When I deploy my site with CodeIgniter 2.2.0. Any idea what might be the cause? I'm getting this error regardless of using .htacess. If it help, here is a link to the site.

nuSOAP library error when run in CodeIgniter

while running nusoap 0.9.5 i get this error
A PHP Error was encountered
Severity: Warning
Message: Attempt to modify property of non-object
Filename: nusoap/nusoap.php
Line Number: 4694
i found a patch while searching Dr. Google that supposed to solve this probem
nusoap-version-0-9-5-attempt-to-modify-property-of-non-object-in-nusoap-php
and even though it solved the problem while run not from inside CodeIgniter, while i do it came up with a new error
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 0
Filename: nusoap/nusoap.php
Line Number: 4693
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 0
Filename: nusoap/nusoap.php
Line Number: 4695
Fortunately Noah Eltzroth from http://www.noaheltzroth.com/
helped me to solve this problem
after doing this
To fix this problem I modified line 4694 in nusoap.php from:
$this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true;
To this:
$this->schemas[$ns][$ns2]->imports[$ns2][$ii]['loaded'] = true;
if you still get the same error i got in the CodeIgniter, simply add # operator to remove the errors
the script works even though it shows the error, it is fine to hide the error
if (! #$list2[$ii]['loaded']) {
$this->schemas[$ns][$ns2]->imports[$ns2][$ii]['loaded'] = true;
$url = #$list2[$ii]['location'];

Categories