By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,934 Members | 1,441 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,934 IT Pros & Developers. It's quick & easy.

basic question about $variable

P: n/a
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!

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
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:

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:$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

Jul 17 '05 #2

P: n/a
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

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.