background for php file

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

Post Reply
jamie85
Forum Newbie
Posts: 8
Joined: Thu Apr 15, 2004 11:59 am

background for php file

Post 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;
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post 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!
jamie85
Forum Newbie
Posts: 8
Joined: Thu Apr 15, 2004 11:59 am

Post 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 :?
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post 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>
jamie85
Forum Newbie
Posts: 8
Joined: Thu Apr 15, 2004 11:59 am

Post by jamie85 »

thanks for that but the output is still as before :(
User avatar
johnperkins21
Forum Contributor
Posts: 140
Joined: Mon Oct 27, 2003 4:57 pm

Post 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.
jamie85
Forum Newbie
Posts: 8
Joined: Thu Apr 15, 2004 11:59 am

Post by jamie85 »

:oops: 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 »

I don't know what language that is, but I don't think its PHP
User avatar
llanitedave
Forum Commoner
Posts: 78
Joined: Thu Jan 15, 2004 11:24 am
Location: Las Vegas, NV.

Post by llanitedave »

What's this "dienice" function? I haven't seen that one before.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

that's no PHP....
Post Reply