nudl3s Posted January 12, 2017 Share Posted January 12, 2017 (edited) Hello all, I am making promo page, but it's giving me this error "Fatal error: Using $this when not in object context in /home/fhlbg/public_html/application/views/promo_test.php on line 2" file is promo_test.php <?php $this->view("common/header"); ?> <link rel="canonical" href="<? echo site_url() ?>" /> <!-- <link rel="stylesheet" href="/css/bx_styles/bx_styles.css" type="text/css" /> --> <!-- <script type="text/javascript" src="/js/jquery.bxSlider.js"></script> --> <!-- <script type="text/javascript" src="/js/jquery.bxslider.min.js"></script> --> <div class="inner"> <div class="inner shadow"> <?php $query = 'SELECT id, title_bg AS `title_cat` FROM categories WHERE is_active = 1'; $result = $this->db->query($query); ?> <?php foreach ($result->result() as $row): ?> I can't understant how $this is working here, because in the already done page "home.php" is working, both are in the same directory. This is home.php: <?php $this->view("common/header"); ?> <link rel="canonical" href="<? echo site_url() ?>" /> <!-- <link rel="stylesheet" href="/css/bx_styles/bx_styles.css" type="text/css" /> --> <!-- <script type="text/javascript" src="/js/jquery.bxSlider.js"></script> --> <!-- <script type="text/javascript" src="/js/jquery.bxslider.min.js"></script> --> <script type="text/javascript"> jQuery(document).ready(function($) { $('#slider1').bxSlider({ slideSelector: 'div.slide', controls: false, pager: false, pause: 3000, auto: true, autoHover: true, moveSlides: 3, minSlides: 1, maxSlides: 3, slideWidth: 235 }); }); </script> <div class="inner inner-transparent"> <div class="slider-wrapper theme-default"> <div id="slider" class="nivoSlider"> <?PHP If anyone can help me solve this or to explane me how it works here. Edited January 12, 2017 by nudl3s Quote Link to comment Share on other sites More sharing options...
requinix Posted January 12, 2017 Share Posted January 12, 2017 $this will be available if the file is being include()d from within a class. Apparently home.php is being included that way but your new promo_test.php is not. Quote Link to comment Share on other sites More sharing options...
nudl3s Posted January 12, 2017 Author Share Posted January 12, 2017 (edited) So is there any way I can run the page without including it. Edited January 12, 2017 by nudl3s Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted January 12, 2017 Share Posted January 12, 2017 (edited) No. You must properly integrate your page into the application infrastructure like all other pages (however that works). Edited January 12, 2017 by Jacques1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.