I am trying to do this problem:
Create a “hit counter” for your home page i.e., exam1.php. There is a file in the exam folder called COUNTER.TXT that contains the number zero. Your PHP page should do the following steps:

1. Read the counter file
2. Add one to the number value
3. Display the new value
4. Write the new number back to the file

and I have this code:

<? php

//read the file
$count = file_get_contents("counter.txt") ;

$count ++ ; //bump the count by one

//display the new value
echo "You are visitor " , $count ;

//write new value back to disk
$handle = fopen ( 'counter.txt' , 'w+' ) ;
fwrite ( $handle , $count );
fclose ( $handle ) ;

?>

but my code is NOT this issue I don't think.
When I insert this code into my home page. "home.htm"
I see the PHP symbol, but when I go to view the page in a browser I am seeing this:

Parse error: syntax error, unexpected T_VARIABLE in /home/*****c3/public_html/******/Home.php on line 6

Please help.
I think I am setting this PHP up incorrectly but not sure where to start to resolve this issue

I am trying to do this problem:
Create a “hit counter” for your home page i.e., exam1.php. There is a file in the exam folder called COUNTER.TXT that contains the number zero. Your PHP page should do the following steps:

1. Read the counter file
2. Add one to the number value
3. Display the new value
4. Write the new number back to the file

and I have this code:

<? php

//read the file
$count = file_get_contents("counter.txt") ;

$count ++ ; //bump the count by one

//display the new value
echo "You are visitor " , $count ;

//write new value back to disk
$handle = fopen ( 'counter.txt' , 'w+' ) ;
fwrite ( $handle , $count );
fclose ( $handle ) ;

?>

but my code is NOT this issue I don't think.
When I insert this code into my home page. "home.htm"
I see the PHP symbol, but when I go to view the page in a browser I am seeing this:

Parse error: syntax error, unexpected T_VARIABLE in /home/*****c3/public_html/******/Home.php on line 6

Please help.
I think I am setting this PHP up incorrectly but not sure where to start to resolve this issue

Your server is going to parse home.htm like an html file. You need to set this in home.php.

This article has been dead for over six months. Start a new discussion instead.