0

I have moved my codeigniter site to Amazon EC2 server. All of a sudden, it stoped working I fount that the template (php) is treated as HTML and not PHP. Hence variables & functions in template are not executed.

<link href="/<?php=$this->config->item('url_suffix')?>css/sliders.css" rel="stylesheet" type="text/css">
<link href="/<?php=$this->config->item('url_suffix')?>css/buttons.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/<?php=$this->config->item('url_suffix')?>js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/<?php=$this->config->item('url_suffix')?>js/jquery.validate.min.js"></script>
<script type="text/javascript" src="/<?php=$this->config->item('url_suffix')?>js/jquery.cycle.all.js"></script>
<script type="text/javascript" src="/<?php=$this->config->item('url_suffix')?>js/js.slide.js"></script>

This is what I get in the browser

2 Answers 2

1

Write echo before config item

<?php echo $this->config->item('url_suffix') ?>

instead of

<?php=$this->config->item('url_suffix')?>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the comment. This didnt work. CI treats the template as Just HTML and not as PHP. So no code in template works
1

You can also try and go for an alternative syntax :

  <?php echo base_url();?>resources/js/filename.js

Same goes for CSS

I also did something. I made a global helper file and added the following in it :

function load_js($js_file=NULL,$tag=true)
{
if($js_file!=NULL){
    if(file_exists("./resources/js/".$js_file))
        return '<script type="text/javascript" src="'.base_url()."resources/js/".$js_file.'"></script>';
}
}

function load_css($css_file=NULL)
{
if($css_file!=NULL){
    if(file_exists("./resources/css/".$css_file))
        return '<link  type="text/css" rel="stylesheet" href="'.base_url()."resources/css/".$css_file.'" />';
}
}

And I use them in my code by doing the following :

<?php echo load_js('filename.js'); ?>
<?php echo load_js('filename.js'); ?>

Try one of these and reply if the problem persists.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.