Page 1 of 1
background for php file
Posted: Thu Apr 15, 2004 11:59 am
by jamie85
I am new to .php and i have obtained a file which can count hits on a website(shown below).
I was wondering can i change the background colour?
Code: Select all
print "Content-type:text/html\n\n";
$log = "counter.log";
open GETCOUNT, "<$log" or die("Error in $0: $log - $!n");
$hits = <GETCOUNT>;
close(GETCOUNT);
$hits++;
print "$hits";
open COUNT, ">$log" or dienice("Cant open file to WRITE");
print COUNT $hits;
close COUNT;
Posted: Thu Apr 15, 2004 12:00 pm
by magicrobotmonkey
you need to put some html around that guy! That should be part of a larger page which will have html tags where you can change the background along with many other glorious attributes!
Posted: Thu Apr 15, 2004 1:07 pm
by jamie85
heh i tried this>
Code: Select all
#!/usr/bin/perl -wT
<html>
<head>
<title>COunter </title>
</head>
<body bgcolor = "#000099">
print "Content-type:text/html\n\n";
$log = "counter.log";
open GETCOUNT, "<$log" or die("Error in $0: $log - $!n");
$hits = <GETCOUNT>;
close(GETCOUNT);
$hits++;
print "$hits";
open COUNT, ">$log" or dienice("Cant open file to WRITE");
print COUNT $hits;
close COUNT;
</body>
</html>
but that returned a blue background with all the PHP script

Posted: Thu Apr 15, 2004 1:14 pm
by magicrobotmonkey
Code: Select all
Code:
#!/usr/bin/perl -wT
<html>
<head>
<title>COunter </title>
</head>
<body bgcolor = "#000099">
<?php
print "Content-type:text/html\n\n";
$log = "counter.log";
open GETCOUNT, "<$log" or die("Error in $0: $log - $!n");
$hits = <GETCOUNT>;
close(GETCOUNT);
$hits++;
print "$hits";
open COUNT, ">$log" or dienice("Cant open file to WRITE");
print COUNT $hits;
close COUNT;
?>
</body>
</html>
Posted: Thu Apr 15, 2004 1:25 pm
by jamie85
thanks for that but the output is still as before

Posted: Thu Apr 15, 2004 1:32 pm
by johnperkins21
You need to run it on a server. You can't just save it to your local disk and "open" it in your browser.
Posted: Thu Apr 15, 2004 1:47 pm
by jamie85

hehe
ok i've done that and now its returning
Parse error: parse error, unexpected T_STRING in /home/httpd/vhosts/rokettes.co.uk/httpdocs/count.php on line 18
Posted: Thu Apr 15, 2004 1:57 pm
by magicrobotmonkey
I don't know what language that is, but I don't think its PHP
Posted: Thu Apr 15, 2004 2:10 pm
by llanitedave
What's this "dienice" function? I haven't seen that one before.
Posted: Thu Apr 15, 2004 2:34 pm
by vigge89
that's no PHP....