473,405 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

PHP/HTML displays garbage ...

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
Nov 27 '05 #1
5 1227
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.

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

In log.php
...
<?php

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

// Getting the information
$ipaddress = $_SERVER['REMOTE_ADDR'];
$page = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";
$page .= iif(!empty($_SERVER['QUERY_STRING']),
"?{$_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
fclose($handle);

?>
....

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

Sean wrote:
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.

Nov 27 '05 #3
OK, here is the simplest example I can think of.
HarveyP wrote:
In File oddsnsod.htms
...
<META NAME="Date" CONTENT="2005-11-27" SCHEME="Year-Month-Day">
<link rel="stylesheet"
href="http://www.pearblossomhouse.com/mypages.css" type="text/css">
<?php
include '/home/pearblocom/public_html/php_scripts/log.php';
?>
<script language="JavaScript" TYPE="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
...
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.

In log.php
..
<?php

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

// Getting the information
$ipaddress = $_SERVER['REMOTE_ADDR'];
$page = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";
$page .= iif(!empty($_SERVER['QUERY_STRING']),
"?{$_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
fclose($handle);

?>
...


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

Nov 28 '05 #4
sorry tryping error - oddsnsods.html

AND

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:
OK, here is the simplest example I can think of.
HarveyP wrote:

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


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.
In log.php
..
<?php

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

// Getting the information
$ipaddress = $_SERVER['REMOTE_ADDR'];
$page = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";
$page .= iif(!empty($_SERVER['QUERY_STRING']),
"?{$_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
fclose($handle);

?>
...


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

Nov 28 '05 #5
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:
OK, here is the simplest example I can think of.
HarveyP wrote:

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


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.
In log.php
..
<?php

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

// Getting the information
$ipaddress = $_SERVER['REMOTE_ADDR'];
$page = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";
$page .= iif(!empty($_SERVER['QUERY_STRING']),
"?{$_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
fclose($handle);

?>
...


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

Nov 28 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: mike | last post by:
ok here's the problem: I have a page that displays a form for user to select individual fields and to specify their own criteria which is used to query a database and then create an excel...
2
by: Mihir | last post by:
Is CLR a process or a thread? if process then name it... if thread, name its parent process? 2. Is Garbage Colelctor a process or a thread? if process then name it... if thread, name its parent...
6
by: Paolo Pignatelli | last post by:
I have an aspx code behind page that goes something like this in the HTML view: <asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%#"mailto:" &amp;...
8
by: rn5a | last post by:
I have a HTML page named Index.html which is divided into 3 frames. The URL of 2 of the frames are HTML pages but the 3rd frame houses a ASP page. Now when I go to Windows Explorer, navigate to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.