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.

that's my issue.
how do i do this?

Change the line:

echo "You are visitor " , $count ;

to

echo "You are visitor " . $count ;

i got it
thanks

<? php incorrect

<?php correct

point in the right direction,
so true

steer and not push

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.