Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 11-02-2009, 07:39 PM   #11
Daemon Poster
 
Join Date: May 2009
Posts: 690
Default Re: php help

I use netfirms.net to host my site with there free plane
__________________

biferi is offline   Reply With Quote
Old 11-03-2009, 04:49 PM   #12
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: php help

I can't seem to see their free plan? Can you provide a link of the specifications if you're not sure whether it supports php or not?
__________________

berry120 is offline   Reply With Quote
Old 12-01-2009, 11:29 PM   #13
Daemon Poster
 
Join Date: May 2009
Posts: 690
Default Re: php help

Sorry it was a long time before I got back to this post but I keep getting Spam.

The PHP Code for my Hit Counter is this

$filename= "counter.txt" ;
$fd = fopen ($filename , "r") or die ("Can't open $filename") ;
$fstring = fread ($fd , filesize ($filename)) ;
echo "$fstring" ;
fclose($fd) ;

$fd = fopen ($filename , "w") or die ("Can't open $filename") ;
$fcounted = $fstring + 1 ;
$fout= fwrite ($fd , $fcounted ) ;
fclose($fd) ;

Now I know I put it into a TXT File but what name do I call this file
biferi is offline   Reply With Quote
Old 12-03-2009, 11:55 AM   #14
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: php help

Well the easy (though not particularly nice from a programming point of view) way would be to embed that code into your HTML page, and embed that code somewhere (at the top for example) in php tags like the following:
Code:
<?php
$filename= "counter.txt" ;
$fd = fopen ($filename , "r") or die ("Can't open $filename") ;
$fstring = fread ($fd , filesize ($filename)) ;
echo "$fstring" ;
fclose($fd) ;

$fd = fopen ($filename , "w") or die ("Can't open $filename") ;
$fcounted = $fstring + 1 ;
$fout= fwrite ($fd , $fcounted ) ;
fclose($fd) ;
?>

...rest of your HTML
If you rename that file index.php and your server supports PHP, the script should execute each time you load the page and add 1 to the counter.
berry120 is offline   Reply With Quote
Old 12-03-2009, 02:21 PM   #15
Daemon Poster
 
Join Date: May 2009
Posts: 690
Default Re: php help

Thanks for the help but let me see if I have it down right??

Inside my index.html page wherever I want my counter to be placed I put

<?php
$filename= "counter.txt" ;
$fd = fopen ($filename , "r") or die ("Can't open $filename") ;
$fstring = fread ($fd , filesize ($filename)) ;
echo "$fstring" ;
fclose($fd) ;

$fd = fopen ($filename , "w") or die ("Can't open $filename") ;
$fcounted = $fstring + 1 ;
$fout= fwrite ($fd , $fcounted ) ;
fclose($fd) ;
?>


And if my server support PHP I can leave the page as index.html and it sould work.

Do I have all this down right??
biferi is offline   Reply With Quote
Old 12-03-2009, 02:31 PM   #16
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: php help

Quote:
Do I have all this down right??
Almost.

Quote:
And if my server support PHP I can leave the page as index.html and it sould work
As I said above, you'll need to rename your page to index.php.
berry120 is offline   Reply With Quote
Old 12-03-2009, 04:44 PM   #17
Daemon Poster
 
Join Date: May 2009
Posts: 690
Default Re: php help

So I don't have the code right yet??
biferi is offline   Reply With Quote
Old 12-03-2009, 05:56 PM   #18
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: php help

The code looks fine to me, at least at a quick glance. By my "almost" reply, I meant the only thing you had wrong in the previous post was the naming - it'd need to be index.php and not left as index.html.
berry120 is offline   Reply With Quote
Old 12-03-2009, 10:46 PM   #19
Daemon Poster
 
Join Date: May 2009
Posts: 690
Default Re: php help

Thanks for the help but wen I go to my page I don't see a hit counter above my logo I see CODE??????????

www.robertsartgallery.com
what did I do incorect?
biferi is offline   Reply With Quote
Old 12-04-2009, 04:47 AM   #20
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: php help

I can't access that site at the moment (for reasons at my end not yours) but if you see the PHP code and you've entered it correctly then chances are your host doesn't support PHP. This doesn't overly surprise me, as i said earlier a lot of free ones don't.

As an aside why do you want a hit counter anyway? They're really not the nicest or most professional of things at all. How many good, popular and professional looking sites that you know of have them?
__________________

berry120 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 11:24 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0