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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

another include problem

Status
Not open for further replies.

KryptoS

Programmer
Joined
Feb 7, 2001
Messages
240
Location
BE
Hey,

when I include another php file in a php file like this:
<? include(&quot;search.php&quot;); ?> there is no problem.
But when I include it like this:
<? include(&quot;search.php?a=&quot;); ?>, I get the following error:
Failed opening 'search.php?a=' for inclusion (include_path='.;c:\php4\pear')

And I really want to include it like search.php?a= ... so anyone a solution?

The One And Only KryptoS
 
Including a file means you load the source code into the current PHP sourcecode before it is interpreted further.
The included file itself is interpreted as if it were part of the parent file.

Why are you trying to include a file with GET parameters?
What do you really want to achieve?
 
You can't include a querystring like that... can I ask what you're trying to accomplish? Odds are there's a better way to do it... namely something like
Code:
$_GET['a']=&quot;whatever you're trying to pass&quot;;
include(&quot;search.php&quot;);

But since you left the value blank, I'm not sure what you're going for.

-Rob
 
You can use include() with a URL. However, PHP knows the difference between including a file on the filesystem and a file via a network protocol by the presence of a protocol designator (&quot; &quot;ftp://&quot;; complete list here: Otherwise, it assumes the file is on the local filesystem.

Also, you don't specify your OS or PHP version, but there are some additional limits specified on the include() online manual page (

Want the best answers? Ask the best questions: TANSTAAFL!!
 
ok I'll try to explain. I'm not a good programmer but anyway ...

I have a few pages: search.php, index.php, seller.php, etc... but these pages have the same lay-out, same menu, same top image, etc... but only the content is different
No I wanted to make 1 mainpage with the lay-out(main.php) and include the search.php or the index.php. So the search.php and index.php don't need the lay-out-stuff anymore. (I don't know if that is a good way to work). But anyway ... If I include I need search.php?a= because I programmed some stuff in search.php ... so I just need it and otherwise I need to adjust the search.php but that's to mutch work :).

The One And Only KryptoS
 
Keep in mind that although &quot;$a&quot; will not be available universally, $GLOBALS['a'] and $_POST['a'] and $_GET['a'] are.

Use the right reference to the variable, and your functions can be made to work without trying to pass that variable back and forth. Just include the file as if that file's code were being inserted verbatim into the code of the script that invokes include().

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top