PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
jamie85
Forum Newbie
Posts: 8 Joined: Thu Apr 15, 2004 11:59 am
Post
by jamie85 » Thu Apr 15, 2004 11:59 am
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;
magicrobotmonkey
Forum Regular
Posts: 888 Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA
Post
by magicrobotmonkey » Thu Apr 15, 2004 12:00 pm
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!
jamie85
Forum Newbie
Posts: 8 Joined: Thu Apr 15, 2004 11:59 am
Post
by jamie85 » Thu Apr 15, 2004 1:07 pm
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
magicrobotmonkey
Forum Regular
Posts: 888 Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA
Post
by magicrobotmonkey » Thu Apr 15, 2004 1:14 pm
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>
jamie85
Forum Newbie
Posts: 8 Joined: Thu Apr 15, 2004 11:59 am
Post
by jamie85 » Thu Apr 15, 2004 1:25 pm
thanks for that but the output is still as before
johnperkins21
Forum Contributor
Posts: 140 Joined: Mon Oct 27, 2003 4:57 pm
Post
by johnperkins21 » Thu Apr 15, 2004 1:32 pm
You need to run it on a server. You can't just save it to your local disk and "open" it in your browser.
jamie85
Forum Newbie
Posts: 8 Joined: Thu Apr 15, 2004 11:59 am
Post
by jamie85 » Thu Apr 15, 2004 1:47 pm
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
magicrobotmonkey
Forum Regular
Posts: 888 Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA
Post
by magicrobotmonkey » Thu Apr 15, 2004 1:57 pm
I don't know what language that is, but I don't think its PHP
llanitedave
Forum Commoner
Posts: 78 Joined: Thu Jan 15, 2004 11:24 am
Location: Las Vegas, NV.
Post
by llanitedave » Thu Apr 15, 2004 2:10 pm
What's this "dienice" function? I haven't seen that one before.
vigge89
Forum Regular
Posts: 875 Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden
Post
by vigge89 » Thu Apr 15, 2004 2:34 pm
that's no PHP....