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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -