By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,680 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

session variable increment problem

P: n/a
session_start();
$_SESSION['visits']++;
print 'You have visited here '.$_SESSION['visits'].' times.';

why the visit variable is not incremented the next time i enter.

Notice: Undefined index: visits in C:\Program Files\Apache
Group\Apache2\htdocs\session\cookie2.php on line 3
You have visited here 1 times.
Jul 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 10 Aug 2003 06:27:26 -0700, sk***********@hotmail.com (sky2070) wrote:
session_start();
$_SESSION['visits']++;
print 'You have visited here '.$_SESSION['visits'].' times.';

why the visit variable is not incremented the next time i enter.

Notice: Undefined index: visits in C:\Program Files\Apache
Group\Apache2\htdocs\session\cookie2.php on line 3
You have visited here 1 times.


Have you ever set it to zero?

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 16 '05 #2

P: n/a
sky2070 wrote:
session_start();
$_SESSION['visits']++;
print 'You have visited here '.$_SESSION['visits'].' times.';

why the visit variable is not incremented the next time i enter.

Notice: Undefined index: visits in C:\Program Files\Apache
Group\Apache2\htdocs\session\cookie2.php on line 3
You have visited here 1 times. session_start(); if (!array_key_exists('visits', $_SESSION))
{
$_SESSION['visits'] = 0;
} $_SESSION['visits']++;
print 'You have visited here '.$_SESSION['visits'].' times.';

Jul 16 '05 #3

P: n/a
matty <ma*******@askmenoquestions.co.uk> wrote in message news:<6P*****************@wards.force9.net>...
session_start();

if (!array_key_exists('visits', $_SESSION))
{
$_SESSION['visits'] = 0;
}
$_SESSION['visits']++;
print 'You have visited here '.$_SESSION['visits'].' times.';

the script stop at 1 time, why?
Jul 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.