Welcome Guest, Not a member yet? Register   Sign In
Fatal error: Using $this when not in object context
#18

[eluser]beatryder[/eluser]
[quote author="flumps" date="1187231443"]ok it looks like im finally getting some where with the thanks you guys been real stars :d

one small problem one big step for me now though...

next problem is php includes...

any ideas how to include a .php file correctly using it... as my friend has setup

Code:
<?php include("header.php"); ?>

at the top of every page and the same for footer but it seems to be eorring only with that now I get the following error....

Warning: include(header.php) [function.include]: failed to open stream: Operation not permitted in /home/user/domains/domain/public_html/system/application/views/index_view.php on line 1

Warning: include() [function.include]: Failed opening 'header.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/user/domains/domain/public_html/system/application/views/index_view.php on line 1

same for the footer include....

think this has somthing to do with the way php5 is setup correct?[/quote]

no, in fact it has to do with how CI uses PHP files. See when CI loads a view, the includes are relative to the root (where the index.php) file is.

just replace
Code:
<?php include("header.php"); ?>

with
Code:
<?=$header?>

Then in your controller add a line like this:
Code:
$data['header'] = $this->load->view('header',TRUE);

//... some other code maybe?

$this->load->view('index_view',$data);


BTW, adding the "TRUE" parameter makes CI return the contents of the view rather than displaying it.

I hope I was clear enough for you.


Messages In This Thread
Fatal error: Using $this when not in object context - by El Forum - 08-12-2007, 03:38 PM
Fatal error: Using $this when not in object context - by El Forum - 08-12-2007, 04:15 PM
Fatal error: Using $this when not in object context - by El Forum - 08-13-2007, 04:04 AM
Fatal error: Using $this when not in object context - by El Forum - 08-13-2007, 10:04 AM
Fatal error: Using $this when not in object context - by El Forum - 08-13-2007, 04:15 PM
Fatal error: Using $this when not in object context - by El Forum - 08-13-2007, 04:49 PM
Fatal error: Using $this when not in object context - by El Forum - 08-13-2007, 04:51 PM
Fatal error: Using $this when not in object context - by El Forum - 08-13-2007, 04:52 PM
Fatal error: Using $this when not in object context - by El Forum - 08-14-2007, 01:39 AM
Fatal error: Using $this when not in object context - by El Forum - 08-14-2007, 03:45 AM
Fatal error: Using $this when not in object context - by El Forum - 08-14-2007, 09:36 AM
Fatal error: Using $this when not in object context - by El Forum - 08-14-2007, 02:01 PM
Fatal error: Using $this when not in object context - by El Forum - 08-14-2007, 02:04 PM
Fatal error: Using $this when not in object context - by El Forum - 08-14-2007, 02:08 PM
Fatal error: Using $this when not in object context - by El Forum - 08-14-2007, 02:22 PM
Fatal error: Using $this when not in object context - by El Forum - 08-14-2007, 03:20 PM
Fatal error: Using $this when not in object context - by El Forum - 08-15-2007, 03:30 PM
Fatal error: Using $this when not in object context - by El Forum - 08-15-2007, 04:12 PM
Fatal error: Using $this when not in object context - by El Forum - 08-16-2007, 02:30 AM
Fatal error: Using $this when not in object context - by El Forum - 08-26-2007, 05:26 PM



Theme © iAndrew 2016 - Forum software by © MyBB