PHP/HTML displays garbage ...

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am using a PHPed version of  an HTML file in order to include an  
onload function to write to a log file. The problem is that large parts  
of this file display as garbage 9 times out of 10, and sometimes again  
with a refresh.

Question: Is this a HTML or a PHP problem? (it doesn't occur in my other  
HTML only pages)
If it is a PHP problem, is it a question of delaying script execution  
until images are displayed? And how do I do that (or whatever else may  
need doing)?

Thanks for any assistance

Re: PHP/HTML displays garbage ...

It's impossible to know where you are going wrong unless you post up
some code.

All php scripts are executed at server time all the html stuff is
displayed on the client; so it's not possible to delay script
execution until the images are displayed.

Re: PHP/HTML displays garbage ...

In File oddsnsod.htms
<META NAME="Date" CONTENT="2005-11-27" SCHEME="Year-Month-Day">
<link rel="stylesheet"  
href=" " type="text/css">
  include '/home/pearblocom/public_html/php_scripts/log.php';
<script language="JavaScript" TYPE="text/javascript">
function MM_swapImgRestore() { //v3.0

In  log.php

function iif($expression, $returntrue, $returnfalse = '') {
    return ($expression ? $returntrue : $returnfalse);

// Getting the information
$ipaddress = $_SERVER['REMOTE_ADDR'];
$page = "http://";
$page .= iif(!empty($_SERVER['QUERY_STRING']),  
"?", "");
$referrer = $_SERVER['HTTP_REFERER'];
$datetime = mktime();
$useragent = $_SERVER['HTTP_USER_AGENT'];
$remotehost = @getHostByAddr($ipaddress);

// Create log line
$logline = $ipaddress . '|' . $referrer . '|' . $datetime . '|' .  
$useragent . '|' . $remotehost . '|' . $page . "\n";

// Write to log file:
$logfile = sprintf('/home/username/public_html/logs/logs%d.txt',date('m'));

// Open the log file in "Append" mode
if (!$handle = fopen($logfile, 'ab')) {
      die("Failed to open log file");

// Write $logline to our logfile.
if (fwrite($handle, $logline) === FALSE) {
      die("Failed to write to log file");

//close it all up


So could I call log.php from the end of the file with better success?

Sean wrote:

Quoted text here. Click to load it

Re: PHP/HTML displays garbage ...

OK, here is the simplest example I can think of.

HarveyP wrote:
Quoted text here. Click to load it

This html and the php include are stored in a .htms file. I have never
seen that type of file extension before but it doest matter. Is there
something in your webserver configuration that tells the webserver to
process .htms files with the php interpreter?? If not then the php
include will not be executed and will simply just print to the screen.

If you don't know what I am writing about then rename oddsnsod.htms
to oddsnsod.php and try it.

If the same thing is still happening then its because php is not
enabled to work with your webserver.

Quoted text here. Click to load it

All that looks ok. But your using allot of absolute addresses, you can
make things easier on yourself by using relative ones.

Re: PHP/HTML displays garbage ...

sorry tryping error - oddsnsods.html


I have found tonight that my non PHP, HTML only pages are suffering too.  
Is it an ADSL thing? I am new to high speed downloading.

Sean wrote:

Quoted text here. Click to load it

Re: PHP/HTML displays garbage ...

Sorry, dyslexic keyboard last 2 posts ...

oddsnsods.php (not html or htms ...)

The absolute addressing is because I also call log.php from a file in  
another directory,  hence the PHP_SELF reference. I bought the original  
design of the site and have been messing about with it since I gained  
full access., but rearranging the whole file structure is something I  
haven't got around to yet

Worse yet, I surfed one of my other, non PHP pages tonight and found the  
same problem! Perhaps it is an ADSL thing - I am new to high speed  
downloading ...

Apologies for posting in the wrong forum. I shall start this thread  
again in a HTML forum, or an ADSL forum.

Thanks for your time.

Sean wrote:

Quoted text here. Click to load it

Site Timeline