Reply to Re: Error - Cannot pass paramter --> Failed to open stream

Your name:

Reply:


Posted by Jerry Stuckle on 10/01/06 03:33

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=david"
>>>>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><input 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.
jstucklex@attglobal.net
==================

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация