Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Little problem with my counter

Asked Modified Viewed 840 times
C
Catzenjaeger
C
  • Senior Member, joined since
  • Contributed 408 posts on the community forums.
  • Started 137 threads in the forums
  • Started this discussions
asked
Senior Member

Hi i show in my header a little counter. He write a count in a file in my root from my fusion.
This works but i get always a notice in my errorlog like this:

Quote

templates/header.php
session_start(): Cannot send session cache limiter - headers already sent (output started at /...../infusions/news_archive_panel/news_archive.php:4) Zeile: 7
templates/header.php
fopen(cnt.txt): failed to open stream: No such file or directory Zeile: 30
templates/header.php
fclose() expects parameter 1 to be resource, boolean given Zeile: 38
templates/header.php
fgets() expects parameter 1 to be resource, boolean given Zeile: 31


What i have to change for works 100% without errors?
The first error notice is different. Its when i click some buttons in my header navigation.
where is the best place this counter? At the moment is in my themes/templates/header.php but will shown always on startsite.
When i add this counter in my used theme directly it works to but also with error notices


Her my counter (i have add this lines in /themes/templates/header.php


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />

<?php
session_set_cookie_params(3600);       //Session (hier: auf 1 Stunde) zeitlich begrenzen
session_start();                          //und starten bzw. weiterfuehren

if (!defined("IN_FUSION")) { die("Access Denied"); }

//////////////////////////////////////////////////////////////////////////////////////////////////
// COUNTER - Textcounter schreibt in cnt.txt im Root via SEESION GESTÜTZT///////////
/////////////////////////////////////////////////////////////////////////////////////////////////
$fp=fopen('cnt.txt','r+');          //Counter-Datei oeffnen
$c=fgets($fp,10);                   //Counter auslesen
if (!isset($_SESSION['cnt_flag'])){       //Falls neuer Besucher
  $c++;                                      //Counter hochzaehlen
  rewind($fp);                               //Zeiger auf Dateianfang
  fwrite($fp,$c);                            //Counter zurueckschreiben
  $_SESSION['cnt_flag']=1;                //Flag in Session setzen
}
fclose($fp);                           //Datei schliessen

if (iADMIN){            
   echo "<center>Besucher seit 01.02.2016: ".$c ;   
               
   echo "</center>";      
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// ENDE COUNTER //////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
0 replies

3 posts

F
Falk
F
Falk 146
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 12 questions
answered
Super Admin

Place it in footer instead.
0 replies
C
Catzenjaeger
C
  • Senior Member, joined since
  • Contributed 408 posts on the community forums.
  • Started 137 threads in the forums
  • Started this discussions
answered
Senior Member

hmn same errors:

templates/footer.php
fopen(cnt.txt): failed to open stream: No such file or directory Zeile: 29 01. Februar 2016 um 15:27:36
templates/footer.php
fgets() expects parameter 1 to be resource, boolean given Zeile: 30 01. Februar 2016 um 15:27:36
templates/footer.php
fclose() expects parameter 1 to be resource, boolean given Zeile: 37
0 replies
F
Falk
F
Falk 146
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 12 questions
answered
Super Admin

One problem less, I Guess

Quote

session_start(): Cannot send session cache limiter - headers already sent (output started at /...../infusions/news_archive_panel/news_archive.php:4) Zeile: 7


Give your text file write permissions, if the textfile does not exist, create one.
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 3 posts
  • Votes 0 votes
  • Topic users 2 members

2 participants

F
F
Falk 146
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 12 questions
C
C
  • Senior Member, joined since
  • Contributed 408 posts on the community forums.
  • Started 137 threads in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet