Welcome Guest, Not a member yet? Register   Sign In
Loading *some* helpers causes gibberish before view output
#1

[eluser]ZeroLag[/eluser]
Hi guys,
Upon loading *some* helpers I get either gibberish in FireFox () or whitespace in IE being displayed above the view I load. Only some helpers though. Here is what I have.

Code:
$this->load->helper(array('html_date_select', 'proficiency', 'child_age'));

If I load only the "html_date_select" helper there are no issues, but either of the other two presents this problem when the page loads.

Here is the helper code for child_age_helper.php:

Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

function listNumbChildren()
{
    $numChildren = array(
        '0' => "0",
        '1' => "1",
        '2' => "2",
        '3' => "3",
        '4' => "4",
        '5' => "5",
        '6' => "6",
        '7' => "7",
        '8' => "8",
        '9' => "9",
        '10' => "10 or more");
        
        return $numChildren;
}

function listChildAges()
{
    $ages = array(
        ''  => "",
        '1' => "1",
        '2' => "2",
        '3' => "3",
        '4' => "4",
        '5' => "5",
        '6' => "6",
        '7' => "7",
        '8' => "8",
        '9' => "9",
        '10' => "10",
        '11' => "11",
        '12' => "12",
        '13' => "13",
        '14' => "14",
        '15' => "15",
        '16' => "16",
        '17' => "17",
        '18' => "18");                                        
        
        return $ages;
}

?>

and for proficiency_helper.php:

Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

function listProficiency()
{
    $prof = array(
            '1' => "1",
            '2' => "2",
            '3' => "3",
            '4' => "4",
            '5' => "5");

    return $prof;
}

?>

All the pages using these helpers function correctly, they just have junk on the top of the page (or whitespace in IE). Can anyone point me at what I'm doing wrong?
#2

[eluser]Mirage[/eluser]
Looks like something is getting into the buffers before/during loading the files.

Open the file Textwrangler and see if there some non-printable gremlins in the files in question. Only thing I can think of from the top of my head....

Cheers!
#3

[eluser]jcopling[/eluser]
Unfortunately I can't offer a direct solution to this but I was receiving the same results and was able to remove it by commenting out this line in my header file:

Code:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

After I commented that out the gibberish went away.

Like I said, this isn't a solution but maybe another piece in this confusing puzzle.
#4

[eluser]ZeroLag[/eluser]
Huh. Jcopling, you were right. I removed that meta tag, and now I get no gibberish.
Surely someone must have an idea why this is so??

Thanks for the help.
#5

[eluser]christian.schorn[/eluser]
Looks like your Editor/IDE inserts a Byte-Order Mark in your files.

The BOM indicating UTF-8 is "EF BB BF" or "" in ISO-8859-1.

Try saving the source as UTF-8 without BOM or ISO-8859-1.
#6

[eluser]onejaguar[/eluser]
It may be that the character set specified by the web-server in the HTTP Content-Type header is something different. I also wouldn't be surprised if you have a few spaces or /r /n characters after the ?> in your helper. An END OF FILE marker should be the only thing after ?>.

http://www.webstandards.org/learn/articl...c/dec2002/
and
http://htmlpurifier.org/docs/enduser-utf...indcharset
#7

[eluser]jcopling[/eluser]
christian hit it on the head for me.

It took a bit of effort to track down the offending file, but once I did, I simply removed the Byte Order Mark and the problem was resolved.

Thanks a lot.
#8

[eluser]ZeroLag[/eluser]
You guys were right on. I used UTF-8 encoding, and everything works the way it should now. Thanks much.

Steve




Theme © iAndrew 2016 - Forum software by © MyBB