session variable increment problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sky2070

    session variable increment problem

    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\h tdocs\session\c ookie2.php on line 3
    You have visited here 1 times.
  • Andy Hassall

    #2
    Re: session variable increment problem

    On 10 Aug 2003 06:27:26 -0700, skywalker2070@h otmail.com (sky2070) wrote:
    [color=blue]
    >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.[/color]

    Have you ever set it to zero?

    --
    Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
    Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

    Comment

    • matty

      #3
      Re: session variable increment problem

      sky2070 wrote:
      [color=blue]
      > 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\h tdocs\session\c ookie2.php on line 3
      > You have visited here 1 times.[/color]
      [color=blue]
      > session_start() ;[/color]
      if (!array_key_exi sts('visits', $_SESSION))
      {
      $_SESSION['visits'] = 0;
      }[color=blue]
      > $_SESSION['visits']++;
      > print 'You have visited here '.$_SESSION['visits'].' times.';[/color]

      Comment

      • sky2070

        #4
        Re: session variable increment problem

        matty <matt+nntp@askm enoquestions.co .uk> wrote in message news:<6PsZa.913 $z7.260482@ward s.force9.net>.. .[color=blue][color=green]
        > > session_start() ;[/color]
        > if (!array_key_exi sts('visits', $_SESSION))
        > {
        > $_SESSION['visits'] = 0;
        > }[color=green]
        > > $_SESSION['visits']++;
        > > print 'You have visited here '.$_SESSION['visits'].' times.';[/color][/color]
        the script stop at 1 time, why?

        Comment

        Working...