473,729 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error - Cannot pass paramter --> Failed to open stream

One
I have a main.php file that calls a php navigation menu.

I want to pass the menu file a parameter to tell it which menu to
display.

Inside the main.php I have :
include "/home/ottadca1/public_html/includes/leftnav.php?men uid=dave";

But the error is :
Warning:
main(/home/ottadca1/public_html/includes/leftnav.php?men uid=dave)
[function.main]: failed to open stream: No such file or directory in
/home/ottadca1/public_html/1menu.php on line 117

Warning: main() [function.includ e]: Failed opening
'/home/ottadca1/public_html/includes/leftnav.php?men uid=dave' for
inclusion (include_path=' .:/usr/lib/php:/usr/local/lib/php') in
/home/ottadca1/public_html/1menu.php on line 117

However - if use the exact same line without passing a parameter it
works fine.
This works : include "/home/ottadca1/public_html/includes/leftnav.php";

I don't understand. I've used this technique in the past.
Is there some sort of php configuration I am missing ???

THANKS!

Sep 29 '06 #1
9 2189
On 29 Sep 2006 11:41:09 -0700, "One" <da**********@g mail.comwrote:
>I have a main.php file that calls a php navigation menu.

I want to pass the menu file a parameter to tell it which menu to
display.

Inside the main.php I have :
include "/home/ottadca1/public_html/includes/leftnav.php?men uid=dave";
You can't do that. "?" is for URLs, but you're specifying a filename. With the
"?", you're specifying a filename that doesn't exist.

If you want to pass variables into the include file, just set them before you
do the include, they'll be visible in the include file. (Or pass them as
parameters to whatever functions you define in the include file).

--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Sep 29 '06 #2
One

Andy Hassall wrote:
You can't do that. "?" is for URLs, but you're specifying a filename. With the
"?", you're specifying a filename that doesn't exist.
ah ha. I know - In the past I have passed it as a parameter like this :
include "http://www.www.com/file.php?menu=d avid"
This has worked.
If you want to pass variables into the include file, just set them before you
do the include, they'll be visible in the include file. (Or pass them as
parameters to whatever functions you define in the include file).
You mean like this ?

<?php
echo "<form><inp ut type="hidden" name=menuid" value="david"></form>";
include file.php
?>

I thought I did this - and it did not work.
In the php include I used :
$menuid = $_GET['menuid']

Thanks for replying.

Sep 29 '06 #3
One wrote:
Andy Hassall wrote:
> You can't do that. "?" is for URLs, but you're specifying a filename.
With the
"?", you're specifying a filename that doesn't exist.

ah ha. I know - In the past I have passed it as a parameter like this :
include "http://www.www.com/file.php?menu=d avid"
This has worked.
Yes, but its very dangerous unless you really, really know what you're
doing.
>
> If you want to pass variables into the include file, just set them
before you
do the include, they'll be visible in the include file. (Or pass them as
parameters to whatever functions you define in the include file).

You mean like this ?

<?php
echo "<form><inp ut type="hidden" name=menuid" value="david"></form>";
include file.php
?>
No - like

$GLOBALS['menuid']='david';
include ('file.php');

C.

Sep 30 '06 #4
Colin McKinnon wrote:
One wrote:

>>Andy Hassall wrote:
>>You can't do that. "?" is for URLs, but you're specifying a filename.
With the
"?", you're specifying a filename that doesn't exist.

ah ha. I know - In the past I have passed it as a parameter like this :
include "http://www.www.com/file.php?menu=d avid"
This has worked.


Yes, but its very dangerous unless you really, really know what you're
doing.
>>If you want to pass variables into the include file, just set them
before you
do the include, they'll be visible in the include file. (Or pass them as
parameters to whatever functions you define in the include file).

You mean like this ?

<?php
echo "<form><inp ut type="hidden" name=menuid" value="david"></form>";
include file.php
?>

No - like

$GLOBALS['menuid']='david';
include ('file.php');

C.
You don't even need to use globals.

Just

$menuid = 'david';

and in the include file you can use

if ($menuid == 'david') ...

An include acts just like if you cut/paste the code from the included
file in place of the 'include' statement.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Sep 30 '06 #5
One

Jerry Stuckle wrote:
Colin McKinnon wrote:
One wrote:

>Andy Hassall wrote:

You can't do that. "?" is for URLs, but you're specifying a filename.
With the
"?", you're specifying a filename that doesn't exist.

ah ha. I know - In the past I have passed it as a parameter like this :
include "http://www.www.com/file.php?menu=d avid"
This has worked.

Yes, but its very dangerous unless you really, really know what you're
doing.
>If you want to pass variables into the include file, just set them
before you
do the include, they'll be visible in the include file. (Or pass them as
parameters to whatever functions you define in the include file).

You mean like this ?

<?php
echo "<form><inp ut type="hidden" name=menuid" value="david"></form>";
include file.php
?>
No - like

$GLOBALS['menuid']='david';
include ('file.php');

C.

You don't even need to use globals.

Just

$menuid = 'david';

and in the include file you can use

if ($menuid == 'david') ...
Yeah!!

Big thanks to Jerry and Colin. I have successfully impltmented your
solution.

BTW - what is the risk passing the variable to the file via and httP
request ?
The include file has nothing to execute.

thanks again!

Oct 1 '06 #6
One wrote:
Jerry Stuckle wrote:
>>Colin McKinnon wrote:
>>>One wrote:

Andy Hassall wrote:
>You can't do that. "?" is for URLs, but you're specifying a filename.
>With the
>"?", you're specifying a filename that doesn't exist.

ah ha. I know - In the past I have passed it as a parameter like this :
include "http://www.www.com/file.php?menu=d avid"
This has worked.
Yes, but its very dangerous unless you really, really know what you're
doing.
>If you want to pass variables into the include file, just set them
>before you
>do the include, they'll be visible in the include file. (Or pass them as
>paramete rs to whatever functions you define in the include file).

You mean like this ?

<?php
echo "<form><inp ut type="hidden" name=menuid" value="david"></form>";
include file.php
?>

No - like

$GLOBALS['menuid']='david';
include ('file.php');

C.

You don't even need to use globals.

Just

$menuid = 'david';

and in the include file you can use

if ($menuid == 'david') ...


Yeah!!

Big thanks to Jerry and Colin. I have successfully impltmented your
solution.

BTW - what is the risk passing the variable to the file via and httP
request ?
The include file has nothing to execute.

thanks again!
Well, it can easily be changed by the user - being a parameter to the
URL. And if you use:

include ('http://...);

You're making another call to the server, getting it to access and parse
the page and return the results to your current page. If it's a remote
system, you'll probably have to do that. But it's a waste to be doing
it to your local system. Just including the file with:

include ('/path/to/file...');

is much more efficient. Additionally, you get the unparsed page (i.e.
PHP code) which can be executed here, instead of the html output by the
server in the previous include.

And btw - when you do use the first include, you have to make sure you
remove out all of the extra tags, such as DOCTYPE, <head>, </body>, etc.
from the included file output to ensure you are sending valid html to
the client.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Oct 1 '06 #7
One wrote:
I have a main.php file that calls a php navigation menu.

I want to pass the menu file a parameter to tell it which menu to
display.

Inside the main.php I have :
include "/home/ottadca1/public_html/includes/leftnav.php?men uid=dave";

But the error is :
Warning:
main(/home/ottadca1/public_html/includes/leftnav.php?men uid=dave)
[function.main]: failed to open stream: No such file or directory in
/home/ottadca1/public_html/1menu.php on line 117

Warning: main() [function.includ e]: Failed opening
'/home/ottadca1/public_html/includes/leftnav.php?men uid=dave' for
inclusion (include_path=' .:/usr/lib/php:/usr/local/lib/php') in
/home/ottadca1/public_html/1menu.php on line 117

However - if use the exact same line without passing a parameter it
works fine.
This works : include "/home/ottadca1/public_html/includes/leftnav.php";

I don't understand. I've used this technique in the past.
Is there some sort of php configuration I am missing ???

THANKS!
You seem to be confusing HTTP (or rather CGI) and PHP.

The '?arg=value&arg =value' syntax is part of CGI, and is interpreted by
CGI programs running typically on web browsers. While many CGI
programs are written in PHP, the syntax has nothing to do with PHP: the
program that interprets it might be in Perl, VB, Asp, or other languages.

When you use
include('filena me');

you are staying within PHP, telling it to read its some code from
somewhere else.

If you use
include("http://url");

you are telling your PHP programme to send an HTTP request to that
server, and parse the result as PHP code. The server will send back just
what you would get if specified that URL to your browser - which will
not usually be PHP source.

Colin

Oct 1 '06 #8
One

Colin Fine wrote:
One wrote:
I have a main.php file that calls a php navigation menu.

I want to pass the menu file a parameter to tell it which menu to
display.

Inside the main.php I have :
include "/home/ottadca1/public_html/includes/leftnav.php?men uid=dave";

But the error is :
Warning:
main(/home/ottadca1/public_html/includes/leftnav.php?men uid=dave)
[function.main]: failed to open stream: No such file or directory in
/home/ottadca1/public_html/1menu.php on line 117

Warning: main() [function.includ e]: Failed opening
'/home/ottadca1/public_html/includes/leftnav.php?men uid=dave' for
inclusion (include_path=' .:/usr/lib/php:/usr/local/lib/php') in
/home/ottadca1/public_html/1menu.php on line 117

However - if use the exact same line without passing a parameter it
works fine.
This works : include "/home/ottadca1/public_html/includes/leftnav.php";

I don't understand. I've used this technique in the past.
Is there some sort of php configuration I am missing ???

THANKS!

You seem to be confusing HTTP (or rather CGI) and PHP.

The '?arg=value&arg =value' syntax is part of CGI, and is interpreted by
CGI programs running typically on web browsers. While many CGI
programs are written in PHP, the syntax has nothing to do with PHP: the
program that interprets it might be in Perl, VB, Asp, or other languages.

When you use
include('filena me');

you are staying within PHP, telling it to read its some code from
somewhere else.

If you use
include("http://url");

you are telling your PHP programme to send an HTTP request to that
server, and parse the result as PHP code. The server will send back just
what you would get if specified that URL to your browser - which will
not usually be PHP source.

Colin
Big thanks to Colin and Jerry for such concise answers.

Thanks again - everything is working well and as expected.

Oct 3 '06 #9
Colin Fine wrote:
....
You seem to be confusing HTTP (or rather CGI) and PHP.

The '?arg=value&arg =value' syntax is part of CGI, and is interpreted by
CGI programs running typically on web browsers. While many CGI
^^^^^^^^ servers, of course
programs are written in PHP, the syntax has nothing to do with PHP: the
program that interprets it might be in Perl, VB, Asp, or other languages.
Colin
Oct 3 '06 #10

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

Similar topics

4
2309
by: Max | last post by:
public class Entity : System.Windows.Forms.Label { .... protected System.Drawing.Point lastMousePosition; .... } public class Flow : Entity { ....
1
4695
by: kencana | last post by:
Hi all, I was wondering why I always get "failed to open stream: HTTP request failed!" error in either loading a normal or xml file. i don't understand why i can't get the whole result. the result i get is only some part of the respective url (the one i tried to load). The following is my php code to open the file: $file=...
2
14080
by: simbarashe | last post by:
Hie I'm trying to pass variables between pages using URLs however I am encountering the following error when I do so: Warning: main(jobSheetDisplay.php?id=20071403PB136CoA) : failed to open stream: No such file or directory in /home/computio/public_html/gto/index.php on line 43 Warning: main() : Failed opening 'jobSheetDisplay.php?id=20071403PB136CoA' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in...
0
2489
by: prasenjit2007 | last post by:
I have a main form for inputing the (to/from/mesg/file) with the following code:- <html> <body> <table> <tr> <td>To:</td> <td><input type="text" name="to" size="50" value="pras_sandilya@rediffmail.com"></td> </tr>
5
3274
by: xieliwei | last post by:
I have a freshly installed openSuSe 10.2 with PHP4 from http://download.opensuse.org/repositories/home:/michal-m:/php4/openSUSE_10.2/ (openSuSe abandoned PHP4 since version 10, but I have customers who need php4 support) The version strings are as follows: # uname -a Linux server2 2.6.18.2-34-default #1 SMP Mon Nov 27 11:46:27 UTC 2006 i686 athlon i386 GNU/Linux
6
62754
by: Andy2500 | last post by:
Hi, I'd like to upload an image to a folder, then I have 3 diffrents examples but all of them give an error "failed to open stream: Permission denied", althrough the C:\Inetpub\wwwroot is not protected. Any suggestions would be helpful, thank you for your time.
2
2482
by: swethak | last post by:
Hi, when i run my code it gives error as fopen(lib/providers//provider.RVLogic.php): failed to open stream: Permission denied in F:\Facebook\furniture11\Data Mining\public_html\lib\inc\functions.lib.php Line 673 : trigger_error("Failed to open stream to $filename. Permission denied!", E_USER_ERROR); could you plz tell the solution for how to avoid that errors
5
9097
by: tyakimov | last post by:
Hi guys I got a problem On my IIS server I changed the password for the Internet Guest Account 'IUSR_Machine' and suddenly the PHP part of the intranet stopped working. - '... failed to open stream: HTTP request failed! HTTP/1.1 401 Access Denied in ...' My PHP script is very simple: <?php
0
8913
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9280
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8144
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6016
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.