Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 21st, 2006, 12:30 AM
Authorized User
 
Join Date: Jun 2006
Location: bombay, maharashtra, India.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default my session variables not retaining values

  hi all
i have been trying to use session variables but getting no results
my site is multipage and from first page i am storing value in session variable and retrieving it back in other pages but no variable retains its value in other pages
what i did was
if

register global=Off (directive in php.ini)

$page=$_GET["page"];

/*for all other pages*/
if($page > 1)
{
session_start();
 $emp_nos = $_SESSION['MyEmpNos'];

}
else
{/*in my first page*/

  session_start();
  $_SESSION['MyEmpNos'] = $emp_nos;

}

but i am not getting MyEmpNos value retained in further pages

i tried even with
 register global= On (directive in php.ini)
and
used

session_start();
session_register();

 also

but no results then too in variable $_SESSION["MyEmpNos"];
can somebody please help.................i need it urgently ..

nidhi
__________________
nidhi
Reply With Quote
  #2 (permalink)  
Old June 21st, 2006, 11:23 AM
Authorized User
 
Join Date: May 2006
Location: Chesapeake, VA, .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to guillermo
Default

this code is a little hard to understand...

if ($page > 1) ... are you using negative values? When is '$page' ever less than 1? Could you post more of the code? As it is, I can't understand the logic... and, on another note & just out of curiosity, why are you placing your comments after the code for which they are meant?
Reply With Quote
  #3 (permalink)  
Old June 22nd, 2006, 12:40 AM
Authorized User
 
Join Date: Jun 2006
Location: bombay, maharashtra, India.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi
no $page can have in my case NULL or zero value also .
but i have got the solution thanks .
and comments i put for easy understanding of code .
b bye
nidhi

nidhi
Reply With Quote
  #4 (permalink)  
Old June 23rd, 2006, 05:26 AM
Registered User
 
Join Date: Jun 2006
Location: Richards Bay, Kwazulu Natal, South Africa.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the problem is:
register global=Off (directive in php.ini)

To make use of $_SESSION and other variables of similar nature, registered globals must be on.

Have fun,
Dale


Ctrl-Alt-Del
Reply With Quote
  #5 (permalink)  
Old July 7th, 2006, 12:33 AM
Authorized User
 
Join Date: Jun 2006
Location: bombay, maharashtra, India.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

no sorry you are absolutely wrong
$_SESSION[] array can be used in both cases whether register global is on or off
but the only thing is
if it is ON
we cant use $page directly


nidhi
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
my session variables not retaining values nidhimittal PHP How-To 5 June 22nd, 2006 12:35 AM
retaining values of controls inside a datagrid @shish ASP.NET 1.0 and 1.1 Professional 0 March 22nd, 2006 05:49 AM
retaining the session of the databse vmaruv SQL Server 2000 0 April 6th, 2005 10:02 AM
Is it possible for me using session variables into see07 ASP.NET 1.x and 2.0 Application Design 4 March 9th, 2005 07:46 PM
session variables help face Classic ASP Databases 4 September 12th, 2003 03:57 PM



All times are GMT -4. The time now is 11:45 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.