473,401 Members | 2,146 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,401 software developers and data experts.

basic question about $variable

Hello,
I am writing my first website using PHP/MYsql.
I bought some PHP templates to help (from SoftVelocity).
Basically, so far, my application first pulls up a table of key values
from the DB. This 'key' value is basically a component of the key for
each of the 'child' tables.
I click on one of the parent keys in the table and save it's value in
$my_contnum, and move to a page that has a form for entering in a
'child' key value. Some how, $my_contnum gets 'zeroed out'.
When I post to add the child key to its table, the value for
$my_contnum is 0.
My question : shouldn't a $variable to good for the whole session,
across pages.
There is a lot of extraneous code generated by the template, and I may
be missing something, but I can't see where it is being reset.
TIA for any ideas or suggestions!
J

Jul 17 '05 #1
2 1266
Variables only exist for the duration of script execution. If you set
a variable, it will exist until the script finishes. If you want to
have variables available from page to page, you either need to send it
along as an HTTP (GET or POST) variable, or store it in a session. I'm
not sure what your examples look like, but you can read all about
sessions here:

http://www.php.net/session

If you wanted to use an HTTP (GET) variable, the easiest way would be
to create a link on the first page that looked something like:

http://www.mysite.com/page2.php?my_contnum=$my_contnum

When the user clicks on that link (on page1.php) the variable will be
passed along. On the second page, you can get to it by using
$_GET['my_contnum'].

Jul 17 '05 #2
Thanks, that was exactly what I was looking for.
I thought every $ variable acted as a session variable.
Believe me, I do research this stuff before I post...I'm
just a little overwhelmed right now...your help is greatly
appreciated!

Jul 17 '05 #3

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

Similar topics

7
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. #...
56
by: Dave Vandervies | last post by:
I just fixed a bug that some of the correctness pedants around here may find useful as ammunition. The problem was that some code would, very occasionally, die with a segmentation violation...
10
by: Jason Curl | last post by:
Greetings, I have an array of 32 values. This makes it extremely fast to access elements in this array based on an index provided by a separate enum. This array is defined of type "unsigned long...
3
by: Paul K | last post by:
I have a very basic question about ref and variables If I create a variable such a private Form1 mform and then assign mform a variable passed by reference such a Form2(ref Form1 f){mform...
14
by: luis | last post by:
Are basic types (int, long, ...) objetcs or not? I read that in C# all are objects including basic types, derived from Object class. Then in msdn documentation says that boxing converts basic...
7
by: Bob Morvay | last post by:
I am trying to determine how far I should go in encapsulating data. As I understand it, OO practices state to create private member variables and use these variables in your publicly accessible...
2
by: Kristian Frost | last post by:
Hi, Say I wanted to store a variable on my main form, then display it, or react to it, on a User Control I'd made. How would I go about getting the variable from my main form to the User Control?...
7
by: garyusenet | last post by:
This is the first time i've worked with openfile dialog. I'm getting a couple of errors with my very basic code. Can someone point out the errors in what i've done please....
4
by: Macneed | last post by:
i am a newbie, i remember i read a book talking about when u declare a array variable using float ABC = new float; the whole array element in ABC ( ABC to ABC ) will automatic initialize to 0...
14
by: MartinRinehart | last post by:
Working on parser for my language, I see that all classes (Token, Production, Statement, ...) have one thing in common. They all maintain start and stop positions in the source text. So it seems...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.