Reply to Re: PHP/HTML displays garbage ...

Your name:

Reply:


Posted by Sean on 11/28/05 15:48

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.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация