Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 10th, 2005, 07:16 AM
Authorized User
 
Join Date: Jan 2004
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Ashleek007
Default Incrementing session problem

Hi everyone,

Im completing a university project which allows tests to be taken online. The problem is to do with the question generation from the database.

Each test contains 20 questions and i am able to display the first question from the database by setting a variable to 1 (uses a createtest.php then redirects to the test.php) :-

$num = 0;
$_SESSION['QnNumber'] = qn.$num;
(so above is in createtest.php)

This works fine and i have seen the result by echoing the session.

Every time someone answers the question and submits it the page goes to a questioncheck page then redirects using the header function to the test.php again. This then adds one to the session using :-

$_SESSION['QnNumber']++;
$qn = $_SESSION['QnNumber'];

I have also echoed this result to check that it increments and it does, but my problem is that it seems to increment by two and not one everytime the above script is run?!

Has anyone got any ideas why this is?

Thanks
Ash:(

My new web design domain
www.askmultimedia.co.uk
__________________
My new web design domain
www.askmultimedia.co.uk
 
Old April 13th, 2005, 08:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 101
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Moharo
Default

Quote:
quote:
$_SESSION['QnNumber'] = qn.$num;
i'm not sure but i never seen notation like this...

since all you have to do is to increment a variable by one each time, wouldn't it be better if you passed it by url and perhaps added 1 to it? :D

www.campusgrind.com the college portal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Incrementing the variable value Swetha XSLT 2 April 28th, 2008 04:43 PM
reading and incrementing a value phantom3008 ASP.NET 1.0 and 1.1 Basics 0 April 18th, 2007 10:29 AM
For Loop Not incrementing donrafeal7 Javascript 1 October 24th, 2006 12:24 AM
incrementing value of a variable akibaMaila VB.NET 2002/2003 Basics 4 July 5th, 2005 12:04 PM
session and cookie problem (empty session file) msincan BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 February 27th, 2005 05:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.