Welcome Guest, Not a member yet? Register   Sign In
Source Code occasionally getting displayed in the browser
#1

[eluser]Unknown[/eluser]
Hi Everyone -

Noticed kind of a weird behavior of CI, that it displays portion of the source code once in a while. Mostly when there is a label it tend to display the source code around it. It's very random and mostly the source code display goes off once you refresh the page again.

The annoying part is that it keep displaying the source code once in a while consistently. Also, I've noticed this when using Google Chrome.

Is that a bug in CI? Or is it something that I'm missing?

Please let me know.

Thanks in advance.
#2

[eluser]skunkbad[/eluser]
You should share some code so we can see what you are doing wrong.
#3

[eluser]stijnvdb[/eluser]
I'm having the exact same issue - seemingly random html source code is getting displayed in Chrome at random moments. When you refresh the page it's displayed normally. Other browsers don't have this issue.
It only happens with my CI installations.

Basically every view is affected and there isn't really anything 'special' about any of them.
I'll post some examples anyway:
Code:
<td valign='top' width='80%'>&lt;?=$event->description?&gt;</td>
the $event->description var sometimes contains an html-tag, like "<p>", which just gets displayed in the browser instead of being parsed for some reason.
The only thing 'special' about this code that I see here is that I'm using short-tags, but these are being handled by PHP, and I have $config['rewrite_short_tags'] set to FALSE in my config.php so there should be no conflict either.
Sometimes it also happens with code that isn't echoing a variable, like here:
Code:
<td>&lt;?=anchor('guestbook/manage', 'Guestbook beheren')?&gt;</td>
- which sometimes displays in the browser as " onium/guestbook/manage">Guestbook beheren" which weirdly links to "http://localhost/panddem&lt;script type=". You see what's happening...

Also, *all* of my CI projects suffer from this - both the live versions (most of them hosted on One.com) and also my localhost ones.


Any ideas?
#4

[eluser]danmontgomery[/eluser]
Sounds like an extension gone awry.
#5

[eluser]stijnvdb[/eluser]
Any idea where I should start looking...? I've been having this issue for a while now.
#6

[eluser]skunkbad[/eluser]
[quote author="stijnvdb" date="1279109973"]Any idea where I should start looking...? I've been having this issue for a while now.[/quote]

Probably in the controller, model, library, or view that is generating the error. I asked you earlier to post some code. It will be nearly impossible to help you unless you do so.
#7

[eluser]stijnvdb[/eluser]
That was a different poster mate! Smile
Regardless, I already posted some code of views that have the issue (see a couple posts earlier) - and here's the controller and model code for the first one (the one where the variables - fetched from db - can contain html-tags like
Code:
<p>
, which are for some reason displayed in the browser instead of being parsed):

Controller:
Code:
function Event()
    {
        parent::Controller();    
        $this->load->helper('typography');
        $this->load->helper('form');
        $this->load->library('validation');
        $this->load->model('eventmodel');
        $this->load->model('bandmodel');
        $this->data['title'] = "Events";
    }

    function getUpcoming($count = 0)
    {
        $data['upcoming'] = $this->eventmodel->getUpcoming($count);
        if($data['upcoming']->num_rows() > 0)
        {
            $this->data['main'] = $this->load->view('event/upcoming', $data, TRUE);
        }
        else
        {
            $data['upcoming'] = $this->eventmodel->getPast($count);
            $this->data['main'] = "<h3>Afgelopen evenementen:</h3>";
            $this->data['main'] .= $this->load->view('event/upcoming', $data, TRUE);
        }
        $this->load->view('layout/layout', $this->data);
    }
    
    function index()
    {
        return $this->getUpcoming(10);
    }

Model:
Code:
function Eventmodel()
    {
        parent::Model();
    }
    

    function getUpcoming($count = 0)
    {
//        $this->output->enable_profiler('TRUE');
        $this->db->where('date >=', date("Y-m-d"));
        $this->db->limit($count);
        $this->db->orderby('date');
        return $this->db->get('pand_events');
    
    }

And here's the second one, this is the one that has it near the &lt;?=anchor('...')?&gt; function:

Controller:
Code:
function Admin()
    {
        parent::Controller();    
        $this->load->library('validation');
        $this->load->helper('form');
    }
    
    function index()
    {
        if (! $this->session->userdata('admin_id')) { redirect('/admin/login'.$this->uri->uri_string(), 'REFRESH'); }
        // adminpanel
        
        $this->data['title'] = "Adminpanel";
        $this->data['main'] = $this->load->view('admin/panel', NULL, TRUE);
        
        $this->load->view('layout/layout', $this->data);
    }

(no model is used here)

However, I suspect that the code I just posted is pretty much irrelevant to my problem. As far as I know I'm not doing anything special here - I'm not using my own libraries and haven't touched CI core either, and the problem I'm describing is happening pretty much *everywhere*. These are just two examples of pages where the problem randomly presented itself when I wanted to recreate it to show you what's going wrong, but in reality I have this problem all over my website - which is why I think the problem is more likely to be config-related or something like that? I have a standard CI installation and pretty much a standard config as far as I can tell.
#8

[eluser]minerbog[/eluser]
[quote author="stijnvdb" date="1279051666"]I'm having the exact same issue - seemingly random html source code is getting displayed in Chrome at random moments. When you refresh the page it's displayed normally. Other browsers don't have this issue.
[/quote]

Seems to me that it could be (dare I say it!) a problem at Google's end :red: . You say the problem occurs randomly and when you refresh the page it goes away. Also that other browsers don't have the same problem.

I would be interested to know if it is CI tho :bug: .
#9

[eluser]stijnvdb[/eluser]
Yeah, it's the combination I guess. There's a definitely a problem at Chrome's end since it's behaving differently from the other browsers in this way, but also a problem with my CI installations since my regular php projects don't have this issue.
CI + Chrome = fail? Sad
#10

[eluser]minerbog[/eluser]
Just reading back over the last few posts and this concerns me slightly.

[quote author="stijnvdb" date="1279112181"](the one where the variables - fetched from db - can contain html-tags like
Code:
<p>
, which are for some reason displayed in the browser instead of being parsed):
[/quote]

From this sentence it says to me that you are getting raw html from a db query. Don't want make anyone sound stupid, but are these being escaped before inserting into the db?? If not these can cause random errors when echoed back into a html file.




Theme © iAndrew 2016 - Forum software by © MyBB