Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML Code randomly appearing unexpectedly

Status
Not open for further replies.

Grahamsccs

Programmer
May 1, 2004
6
GB
Hi all,

I wondered if anyone could help me. For a long time now, i've experienced problems with a Perl script whereby small sections of HTML code show up, sometimes terminating the script there and then. For example, it will show part of the script output, but terminate by actually displaying a small section of HTML code like "<td><font si". The snippet it shows is completely random, and when it occurs is also random. Technically speaking, it should produce the same HTML output every time, so why should this problem be so random?

The script itself is producing a calendar and booking display so there is a considerable amount of HTML. I've used a validator to make sure i've removed any potential errors, but the problem still remains. Could even small validation errors give rise to this random occurance?

I've combed the script many many times now. There is a content type of text/html printed in the headers along with the cookies and is working fine. The only other thing to note is that the script makes use of a mySQL database and runs a number of queries to produce the output. I've checked the entries and none of the text has strange quotes that could terminate the HTML, and even if it did, wouldn't it do it every time?

If anyone could suggest something to try, id be very grateful.

Graham
 
if this is a web page check:
server error log
db error log
set -w and run it from the command line see if it reports problems
set -wT and run it from the command line see if it reports problems
use strict and run it from the command line see if it reports problems.


the best idea might be to save a copy as a .txt and then post the link here.
 
I've checked the server log, i'll need to have a look at the mySQL database logs, but I don't think that it could cause this problem. Using strict only picks up some global value errors, I think because it's not actually checking my config.cgi script for all the global definitions.

What do the -w and -wT options do?
 
Maybe you have a die command in there somewhere?
Maybe a variable that reads like HTML and you print something like:

print "$a";
and $a = "<something";

Lot of possabilities. Need to see the code.
 
There are over 10,000 lines of code. There are die commands in there, but only on the SQL queries. Additionally, if the die command is invoked, it always produces output.

One thing I forgot to mention, was that when this random HTML is printed, the browser attempts to refresh itself automatically, often succeeding, sometimes just going to a standard IE page not found screen. The strange thing is that it is completely random. The code may be following exactly the same path it has done before when it succeeded, but on that occasion, produces this weird output. Have you ever seen this before on a script?
 
Used -WcT and got a few minor errors back, mostly with overshadowed scalars which i've resolved. There are now no errors showing up, but the problem persists. The web server logs show no errors, neither to the mySQL error logs. Any suggestions?
 
I would wager that as the html is being built that a ending > is being left out or something like that. Have you taken a close look at what code is being created upto the point it stops. When it breaks "view source" and check that has been created to that point.
 
I thought that that could be the problem, but you see, the HTML that is printed is entirely random, it seems as though it can be from absolutely anywhere in the script. The script can also therefore terminate at ANY point in loading. It can parse 1/4 of the script and spout some HTML and terminate or get almost to the end and then spout some HTML. Other times, it can load the script perfectly without errors, even though the last time it loaded that exact output it caused this strange problem.

I would attempt to view source, but unfortunately, like I said, it attempts to reload before I can managed it. I've run a validator on the HTML, and there aren't any major problems. There are a few quotes missing off places like around color tags and things, but if this doesn't cause a problem normally for the browser, could it actually be the cause?

I'm at my wits end I think.
 
I wish I could help but without seeing the code it is like trying to find a needle in a haystack.
 
Are there any other things I can try to attempt to diagnose the issue? Are there known issues whereby Internet Explorer, Apache, mySQL or PERL can randomly mess up like this?
 
you checked apache and sql logs so you know that isn't it.
You turned on the perl error checking and that didn't expose anything. you use strict to check for variable altering. All the easy bases have been covered.
 
When you run it on the command line pipe it to a text file, and then review the output in a browser.

The refresh, or redirect, should have been output in the header, unless its a javascript problem.

Are you requiring any files, particularly "offsite" resources that you don't have 100% control of?

"<td><font si

This actually looks like a timeout or dead process issue, if that's the last value in the output. Are you on a shared server, it could be that the admins are throttling your bandwidth because of your CPU usage, and bandwidth requirements. If they're killing the jobs with extreme prejudice it's unlikely that it's going to get a chance to write to the logs

10,000 lines of code in a single script, how many potential users access this site at one time?

It may be time to reconsider reengineering the project using modules, or running under mod_perl to spped things up

Just a few thoughts

Like the lads said, it's not going to be easy without seeing some code

HTH
--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ... smack the fecker
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top