function - Why PHP include is not working? -


i'm trying make page view counter. i'm newbie php. here problem: i'm using code in "index.php":

<?php     include "visitcounter.php"; ?> 

and using following code in "visitcounter.php":

<?php session_start(); if(isset($_session['visitcount']) {     $_session['visitcount'] = $_session['visitcount']+1; } else {     $_session['visitcount'] = 1; }  echo "total page views = ".$_session['visitcount'];  ?> 

the problem page index.php showing server error. if change code following code in index.php:

<?php     include "/visitcounter.php"; ?> 

then page not show error message display nothing. please me figure out wrong i'm doing.

first of all, point mentioned of silvio silva problem.

change from:

session_start() 

to:

session_start(); 

to avoid such problems in future, add file:

ini_set("display_errors","on"); error_reporting(e_all); 

this show such errors directly in output, can find easier.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -