473,387 Members | 1,561 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

My PHP/Web page does not persist data when page is refreshed. Sample code attached

I can't persist data when my php page is refreshed.

I expect the following code to increment the value of views each time the page is refreshed until the user closes their browser. It doesn't. Output is always "views = 1."

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();  
  3. if(isset($_SESSION['views']))
  4.     $_SESSION['views'] = $_SESSION['views'] + 1;
  5. else
  6.     $_SESSION['views'] = 1;
  7.  
  8. echo "views = ". $_SESSION['views']; 
  9.  
  10. print_r($_SESSION);
  11. ?>
Apr 23 '13 #1
1 1107
omerbutt
638 512MB
it is working for me perfectly try using @ before session_start(); like this
Expand|Select|Wrap|Line Numbers
  1. @session_start();  
  2.  
also check if sessions are enabled in you php.ini go to xampp home page by typing http://localhost in your browser and open phpinfo() and search for session you will seee the fllowing there
session
Session Support enabled
Registered save handlers files user sqlite
Registered serializer handlers php php_binary wddx
regards,
Omer Aslam
Apr 24 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: news.rcn.com | last post by:
How can I access the request and response object for a page using javascript. I want to stick some data on with something like request.setAttribute( "User's choice for later use" ). I can't seem...
0
by: NB | last post by:
Hi My file server runs Win 2000 Pro and has Office XP installed. I host a data access page contaning Pivot Table on the server. In the page body I have some reference to an lpk file on the...
2
by: Roy Scarisbrick | last post by:
I have a programming issue on an ASP.Net web page. I suspect the issue would apply to any version of ASP though. I have a questionnaire page where a user will answer a bunch of questions with...
3
by: Brad | last post by:
I have a response filter which injects "standard" html into my pages. The filter works fine when the initial stream is small enough not to buffer...or....if I have a large unbuffered stream (i.e. I...
1
by: Grey | last post by:
There is a ASP.NET web form for user input data, user can also click one button to trigger another asp.net web form for lookup purpose. My problem is when the user choose data from the lookup form...
1
by: Peter | last post by:
I have an array MyArray(30,3) The string data looks like this: MyArray(0,0) = "ColumnA";MyArray(0,1) = "ColumnB";MyArray(0,2) = "ColumnC" MyArray(1,0) = "DataA";MyArray(1,1) =...
1
by: Andrew K | last post by:
Hi, This is a problem I noticed in one of my applications the other day and can't figure out how to fix. In the attached code I have 2 forms. The form named form1 is the MDI container, form2...
4
by: Henry | last post by:
Does anybody have a real-world sample of buiding a treeview control using data from database tables? All the sample code I have found either builds the treeview manually or uses a file directory...
4
by: evantay | last post by:
I'm using ASP.NET 2.0 with VS.NET 2005. I'm trying to access properties from my master pages within a page that inherits from that master page (a child page). However the values are always null....
0
by: Andrus | last post by:
MSDN Winforms DataGridView VirtualMode with caching sample code DataRetriever loads two pages always to cache thus making 2 database accesses. If datagridview uses one page of data, second page...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.