473,394 Members | 1,887 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,394 software developers and data experts.

Accessing GET variables with include file

There is probably an easy solution to this that I've overlooked
somewhere...

I have a main file, call it main.php, and an include file,
myInclude.php. I'm accessing main.php via:
http://www.example.com/main.php?page...est&var2=test2

main.php:
-------------------
<?php
$page = $REQUEST['page'];
if($page=="new") include('myInclude.php');
?>
-------------------

and try to access var1 and var2 from the include:
myInclude.php:
---------------------
$var1 = REQUEST['var1'];
$var2 = REQUEST['var2'];
----------------------
both $var1 and $var2 are empty in myInclude.php. How do I "see" var1
and var2 from myInclude.php?

Thanks!

Jan 1 '07 #1
1 1697
$_REQUEST is a superglobal, so it's accessible at any scope. You may
have a typo: Try $_REQUEST instead of REQUEST. You might also set
error_reporting(E_ALL) to potentially catch some errors.

If you want just query string parameters, you could use $_GET instead
of $_REQUEST. There's also $_POST for posted variables.

Greg Scharlemann wrote:
There is probably an easy solution to this that I've overlooked
somewhere...

I have a main file, call it main.php, and an include file,
myInclude.php. I'm accessing main.php via:
http://www.example.com/main.php?page...est&var2=test2

main.php:
-------------------
<?php
$page = $REQUEST['page'];
if($page=="new") include('myInclude.php');
?>
-------------------

and try to access var1 and var2 from the include:
myInclude.php:
---------------------
$var1 = REQUEST['var1'];
$var2 = REQUEST['var2'];
----------------------
both $var1 and $var2 are empty in myInclude.php. How do I "see" var1
and var2 from myInclude.php?

Thanks!
Jan 1 '07 #2

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

Similar topics

3
by: Leigh Riley | last post by:
Hi, Can someone tell me if the following is possible? I have a file containing some STATIC variables, and some functions e.g. -------------------------------------------------...
23
by: Mark Parnell | last post by:
I'm relatively new to PHP, and have just converted a site from ASP to PHP. There is one thing I haven't managed to do, though. When the site was using ASP, I had one file (called variables.asp),...
3
by: Peter | last post by:
Hello, Two newbie questions: 1) I have a javascript file with a function in it. From this function I want to access a variable in another javascript file -which is not inside a function. I...
8
by: scott | last post by:
hi, sorry if this has been adressed some where elss. if it has plz can you point me to it and ill go read it. any way, i want to declare some variables with in a header file. lets say int i; ...
2
by: Patient Guy | last post by:
I have a library of functions representing a filesystem interface (essentially a file selection interface, to be used in opening/reading/writing/closing files). Heavily scripted HTML document...
1
by: jgamble | last post by:
Hi, Here's a question for you all. Under "classic" ASP any ASP page could have any number of #Include files. Using #Include files I could have functions which were common to my whole site and...
1
by: Greg Scharlemann | last post by:
There is probably an easy solution to this that I've overlooked somewhere... I have a main file, call it main.php, and an include file, myInclude.php. I'm accessing main.php via:...
2
by: Jurek Dabrowski | last post by:
hi all, I have a question in reference to accessing variables in another class maybe someone has dealt with before. I have some public variables declared in my main plug-in class...
1
tolkienarda
by: tolkienarda | last post by:
hi all i have an have a script that i include in my program that validates a form, i was wondering if it would be possible to access variables from that script in my main script. example...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.