basic question about $variable

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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!

Re: basic question about $variable

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

Re: basic question about $variable

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

Site Timeline