Help with script that has some html in it

Started by Tom, November 10, 2003, 09:55:45 PM

Previous topic - Next topic

Tom

I'm a newbie to php, and I'd be really happy if someone can help me.
Here is the code for an ip logging script that I am using:


$log_file
= "log.html";

$time = date("h:i:s A");
$date = date("Md-Y");
$domain = gethostbyaddr("$REMOTE_ADDR");
$IP = $REMOTE_ADDR;

$message = "$time | $date | $IP | $domain";

$fedit = fopen("$log_file", "a") or die("file unable to be opened");
fread($fedit, filesize("./$log_file"));
fwrite($fedit, "$message<br><hr>");
fclose($fedit);



It works perfectely if it is just by itself, but when I try to put it with my site that is in html, the <br> and <hr> mess it up.  Is there anything I can do to work around this, other than just leave out the <hr> and <br>?

Thanks.

morph

maybe something simple like this?

<?php
$log_file
= "log.html";

$line = "<br><hr>";
$time = date("h:i:s A");
$date = date("Md-Y");
$domain = gethostbyaddr("$REMOTE_ADDR");
$IP = $REMOTE_ADDR;

$message = "$time | $date | $IP | $domain";

$fedit = fopen("$log_file", "a") or die("file unable to be opened");
fread($fedit, filesize("./$log_file"));
fwrite($fedit, "$message | $line");
fclose($fedit);

?>


Might be wrong, new to php but if i'm not mistaken that should work.

EDIT: you could also add $line in the message

Coming soon!

Tom

Hmmm, it still sees the <hr> and makes a line.  ::)

Thanks anyway.

jrcarr

Quote from: Tom on November 10, 2003, 10:27:45 PM
Hmmm, it still sees the <hr> and makes a line.  ::)

Thanks anyway.
What am I missing here?  The <hr> is suppose to make a line in html! What are you expecting from it here?

Jack
Jack Carr

[Unknown]

Uhh... if you want an actual <hr />... use &lt;hr /&gt;.

-[Unknown]

Advertisement: