Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass variablis between php files? 1

Status
Not open for further replies.

csnowbar

Programmer
Apr 3, 2001
2
US
Hi,

I have a file named MakeModel.php that queries a database and sends back a tree-style list containing makes and models of equipment which looks something like this:

Make
+Model
+Model
+Model
+Model
Make
+Model
+Model
+Model
+Model...

and so on. Each of the model names are hyperlinked to a different php file that should open in a different frame so the user can see the names of equipment available in that make and model. How do I send a variable named "$m" (which stands for the model) to the other php file so that it can reference it in a different query?

I'm using this right now, but the other php file is not able to parse the "$m" variable:
&quot;<A HREF='availableequipment.php?m=$model' target=\&quot;makemodellist\&quot;>$model</A> &quot;
Any ideas? Any help that anyone can give me would be muchly appreciated.

Regards,
Craig Snowbarger
 
Craig, the method you are trying to use looks fine - you are using the GET method(putting variables you are passing to the next script right on the URL line of a link). The next script, availableequipment.php, should be able to see the $m variable - things to try:

1. Make sure availableequipment.php is actually being invoked when you click on the link - put &quot;error_log&quot; statements at the top of availableequipment.php, and then check your webserver error log file.

2. You should be able to print out the value of $m this way too.

How you reference variables depends on your PHP setup - in your php.ini file. Look at the value of &quot;register_globals_gpc&quot; - if it is &quot;on&quot;, then in availableequipment.php you should be able to refer to $m. If it is &quot;off&quot;, then you will probably need to refer to $m like this:

$HTTP_GET_VARS[&quot;m&quot;]

If you still can't get it to work, post more details - what are the values of:

register_globals_gpc
error_reporting
display_errors
log_errors

in php.ini, what error_log statements you have and what the webserver error log is showing for those error_log's, etc.

Also, I'm not sure what the

target=\&quot;makemodellist\&quot;

part of the HREF does - I've never used that.

HTH.
Hardy Merrill
Mission Critical Linux, Inc.
 
Hmerrill:
If his page is in frames, then the target=\&quot;makemodellist&quot; points to the name of the frame that he wants the link to open in.

csnowbar:

Is your page in frames? If so, I think that might have something to do with it.

But from what Hmerrill has said, I think he might have solved your problem.

Hope this helps.
-Vic vic cherubini
vikter@epicsoftware.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director
====
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top