I'm having a problem with my PHP script that I just can't figure out for the life of me.
My script is rather large (?) at over 1800 lines, so I won't bother wasting bandwidth posting it all.
The problem I'm having is that the script is outputting 'garbage' to the browser before anything that I specify as output from the script. For example,
I have a function to initialize a frameset on the client-side, using the 'print' function. While there are other functions that ultimately call this function, I've made very sure that NOTHING is output to the browser prior to this point.
function InitSite($siteMode)
{
if (!$siteMode)
{
$browserType = detBrowserType();
if (strcasecmp($browserType,"DHTML") == 0)
{
print("<HTML><HEAD><TITLE>Frameset</TITLE></HEAD>\n");
print(" <FRAMESET ROWS=\"0%,0%,*\" SCROLLING=AUTO NORESIZE BORDER=0>\n");
print(" <FRAME SRC=\"" . basename($_SERVER['SCRIPT_NAME']) . "?mode=CONTROL\" NAME=CONTROLFRAME SCROLLING=NONE NORESIZE>\n");
print(" <FRAME SRC=\"\" NAME=DATAFRAME SCROLLING=NONE NORESIZE>\n");
print(" <FRAME SRC=\"\" NAME=DISPFRAME SCROLLING=NONE NORESIZE>\n");
print(" </FRAMESET>\n");
print("</HTML>\n");
}
}
else
{
// Other HTML is displayed depending on the 'siteMode' passed to the function.
}
}
Above, the function 'detBrowserType', currently only returns the string 'DHTML', and that's all.
And even after making sure that nothing may have been accidentally output to the browser prior to the <HTML> tag above, I always get random lengths (usually a maximum of 5-6) of random characters (most are non-alphanumeric ASCII characters). For example, right now all it's displaying is the letter 'Q'. Earlier it was displaying something like:
O`* <HTML><HEAD><TITLE>Frameset</TITLE></HEAD>
<FRAMESET ROWS="0%,0%,*" SCROLLING=AUTO NORESIZE BORDER=0>
<FRAME SRC="index.php?mode=CONTROL" NAME=CONTROLFRAME SCROLLING=NONE NORESIZE>
<FRAME SRC="" NAME=DATAFRAME SCROLLING=NONE NORESIZE>
<FRAME SRC="" NAME=DISPFRAME SCROLLING=NONE NORESIZE>
</FRAMESET>
</HTML>
Internet Explorer, luckily, ignored these characters and processes the page normally... but Mozilla takes a different approach, and merely displays those random characters to the screen, ignoring the HTML that comes after it.
I do not use output buffer control (ob_start(), flush(), ob_end_flush(), etc.), but thinking it might solve the problem, I briefly used it only to be disappointed and even more confused.
Anyone have any ideas as to why this might be happening and what might be done to resolve it?
Thanks,