0

Hello ,
I am stuck on this line of code

echo $hits[0];

i am trying to get it to echo into a text box as an integar. at the moment the code

<?php
$count_my_page = ("hitcounter.txt");
$hits = file($count_my_page);
$hits[0] ++;
$fp = fopen($count_my_page , "w");
fputs($fp , "$hits[0]");
fclose($fp);
echo $hits[0];
?>

when run on

<?php
    include ("counter.php");
    ?>

just gives me a number
I have been thinking along trying to get

<?php
    include ("counter.php");
    ?><HTML><HEAD>
</HEAD><BODY><INPUT value="ehco $hits" name="Hit counter"></BODY></HTML>

to work ,
thanks.

3
Contributors
2
Replies
7
Views
6 Years
Discussion Span
Last Post by tomato.pgn
1

first off lets fix the counter.php code

<?php
$count_my_page = ("hitcounter.txt");//please take in consideration that the file hitcounter.txt already exists
$hits = file($count_my_page);
$hits[0]++;
$fp = fopen($count_my_page , "w");
fputs($fp , $hits[0]);
fclose($fp);
echo $hits[0];
?>

And now to embed the code in a textbox

<html>
<head>
</head>
<body>
<input name="Hit Counter" type="text" value="<?php include ("counter.php"); ?>">
</body>
</html>

I hope this solves your problem
please reply back if things didn't work for you.

1
<?php
include ("counter.php");
?>
<HTML>
<title>
Verified by tomato.pgn
</title>
<HEAD>
</HEAD>
<BODY><INPUT type="text" value=<?php echo $hits ?> name="Hit counter">
</BODY>
</HTML>

Hope this will fix ur error.....
if any other problem PM me....

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.