Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-29-2004, 02:19 AM   #1
LQ Newbie
Registered: Mar 2004
Posts: 1

Rep: Reputation: 0
php session array : What's wrong in this code

Dear ALL


I am trying to accumulate values in an array.

I am happy with the value stored in variable page_views

However the array defines is initialised...

May be I had not defined properly

Can any one help me to store valued in session array....

May be (rather certainly) there is an error..

Thanks in advance
Vikas Athavale



echo "<br> count= ".$k."<br>";
$_session["arv"] [$k]= $page_views;

echo "<br>value stored in session var arrayvariable = ".$_session["arv"] [$k] ."<br>";

echo "<br> _session count= ".count($avar)."<br>";

echo "You have viewed this page ";
echo $page_views;
echo " times(s).";

Old 03-29-2004, 10:15 AM   #2
Registered: Feb 2004
Location: MD
Distribution: Fedora 9
Posts: 129

Rep: Reputation: 15
If im understanding it, looks to me that everytime you declare $arv=array(); you are essentially wiping out the old data with an empty array.

Try testing for it being equal to null before declaring it as an empty array... no need to declare it if its already stored in a session.
Old 03-30-2004, 08:37 AM   #3
LQ Newbie
Registered: Jan 2004
Location: Estonia
Distribution: Gentoo
Posts: 20

Rep: Reputation: 0
The biggest mistake in your code is that you are tring to access global variables the wrong way.. all the global variables are with capitalized letters, like: $_GET, $_POST, $_SESSION, $_COOKIES, $_SERVER, etc..

Note: $arv isn't the same as $_SESSION['arv']

And at:
PHP Code:
$_SESSION["arv"][$k]= $page_views
You haven't set the $page_views so you assign empty value for $_SESSION["arv"][$k]

Hopefully you understand me


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Are PHP session variables held in memory when you leave a PHP site? Locura Programming 11 11-16-2008 08:37 PM
array of unions (c code) alaios Programming 6 09-16-2005 11:43 AM
PHP something wrong with the code :( Alexander.s Programming 2 04-22-2005 04:27 AM
Only 1 choice as x-session-manager alternatives, but it's the wrong one. wartstew Debian 7 09-19-2004 08:00 PM
php array gui10 Programming 2 03-26-2002 02:07 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:05 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration