473,549 Members | 2,731 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

session variable problem

#register variable
session_registe r("product1") ;
session_registe r("product2") ;
$product1="Palm pilot";
$product2="Powe r mac 5";

#print variable from another page
print "Your chosen products are:\n\n";
print "<ul><li>$produ ct1\n<li>$produ ct2\n</ul>\n";

why the above code return

Your chosen products are:
Notice: Undefined variable: product1 in C:\Program Files\Apache
Group\Apache2\h tdocs\session\s ession3.php on line 11

Notice: Undefined variable: product2 in C:\Program Files\Apache
Group\Apache2\h tdocs\session\s ession3.php on line 11
Jul 16 '05 #1
2 5548
sky2070 schrieb:
#register variable
session_registe r("product1") ;
session_registe r("product2") ;
$product1="Palm pilot";
$product2="Powe r mac 5";

#print variable from another page
print "Your chosen products are:\n\n";
print "<ul><li>$produ ct1\n<li>$produ ct2\n</ul>\n";

why the above code return

Your chosen products are:
Notice: Undefined variable: product1 in C:\Program Files\Apache
Group\Apache2\h tdocs\session\s ession3.php on line 11

Notice: Undefined variable: product2 in C:\Program Files\Apache
Group\Apache2\h tdocs\session\s ession3.php on line 11


check your setting for register_global s!

HTH!
rainer

Jul 16 '05 #2
sk***********@h otmail.com (sky2070) schrieb:
#register variable
session_registe r("product1") ;
session_registe r("product2") ;
$product1="Palm pilot";
$product2="Powe r mac 5";

#print variable from another page
print "Your chosen products are:\n\n";
print "<ul><li>$produ ct1\n<li>$produ ct2\n</ul>\n";

why the above code return

Your chosen products are:
Notice: Undefined variable: product1 in C:\Program Files\Apache
Group\Apache2\h tdocs\session\s ession3.php on line 11

Notice: Undefined variable: product2 in C:\Program Files\Apache
Group\Apache2\h tdocs\session\s ession3.php on line 11


Seems simple. In your php.ini register_global s is not set "On". On the
other hand, you can't expect that this value is always "On". On newer
versions of PHP (> 4.0.x) you should use

#register variable
$_SESSION["product1"]="Palm pilot";
$_SESSION["product2"]="Power mac 5";

#print variable from another page
print "Your chosen products are:\n\n";
print
"<ul><li>$_SESS ION['product1']\n<li>$_SESSION['product2']\n</ul>\n";

Matthias
Jul 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6262
by: Nick Whitelegg | last post by:
Hello, I'm having an odd problem with combining an authentication session variable with header() redirection. Basically I have an authentication script which checks a username/password. If the login is correct a session variable containing the username is set and the user is redirected to the (restricted access) main menu page. The...
11
3328
by: doltharz | last post by:
Please Help me i'm doing something i though was to be REALLY EASY but it drives me crazy The complete code is at the end of the email (i mean newsgroup article), i always use Option Explicit and Response.Expires=-1,
1
2011
by: Scott Wickham | last post by:
I'm having a problem saving session information on one form and retrieving it on a subsequent form...for only one out of a number of users. Actually, I'm not absolutely certain it's a session problem but I'm hoping the experts can help me figure that out. Our application uses a session variable to "pass" info from one form to the next. It...
1
1893
by: farooqazeem | last post by:
Hi guys, I’m facing some problem can u solve it. Problem is: I’m giving user Id and password in (Login_sess.asp) and submit it to page (sess_test.asp). I am setting session variable (session(“Sin”)=”Yes”) just before redirecting to the same page, but in first time I do not received the value of session variable when I...
5
4127
by: Marc Rivait | last post by:
Here is a very interesting scenario. I have a simple test application that loads a page and sets a session variable on the load event. On the first page there is a link to a second page. The load event of the second page displays the value of the session variable. The problem is that when I use a W2k machine, this little test works...
9
2444
by: William LaMartin | last post by:
I have a problem, mentioned here before, of Session and Application variables disappearing at one site but not at others or on my development computer. The problem is illustrated by an example at http://www.lamartin.com/dotnet/sessiontestset.aspx, were I set Session, Application and Cache variables on the first page and then on the second...
9
2368
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use - perhaps I'm just not very smart or perhaps MS is making this too hard for us sql bunnies to understand - I dunno, but I'd really appreciate someone...
1
737
by: Werner | last post by:
Hi Patrick! Can you give an example of how to use a frameset inside an aspx-file? When I create a new frameset in Visual Studio.Net it just gives me a htm-File. Or give me a link where I can find one? Thanks Werner P.S. Somehow I did not manage to do a followup in Googles newsgroups.
7
2236
by: Lucas Tam | last post by:
I'm calling the session object from an inherited page. The page is based off an herited class which outputs XML. Does anyone know why the session object would be nothing? httpcontext.current.request/response/etc all work, except for session. Thanks. --
4
1943
by: T Ralya | last post by:
I am told that ASP.NET controls the session ID and session variables, but that does not fit my symptoms. I am posting here as directed. I'm hoping that someone can at least recommend something to try to isolate the problem. I have a simple application that demonstrates my problem. Page 1, step1: SaveSessionVariableButton will create a...
0
7518
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
7715
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7956
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7808
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5087
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.