On 4/5/01 10:56 AM, "Ashley M. Kirchner" <[EMAIL PROTECTED]> wrote:

> 
>   I have a DB project going and every time I query the DB for data
> from a particular table, I want to include a set of variables (that get
> set based on the query result).  I was thinking of doing something like
> this:
> 
>   $sql = "..."
>   $result = ....;
>   include 'variables.php?table=$table';
> 
>   However, every time I try that, it tells me it can't find
> 'variables.php'.  However, if I rename the file to 'variables.inc', it
> does find it (though it doesn't pass any arguments to it then).
> 
>   The first method tells me it's not in the include path.  Okay,
> easily fixable in php.ini, however, I don't want this extra path info to
> apply to the whole server (which is running several vhosts).  How can I
> adjust the include path just for this particular vhost?
> 
>   Or, is there a better way to do what I'm trying to accomplish?  Make
> it a function perhaps?  A call that would look kinda like this perhaps:
> variables($table) ?  But then, how do I get to the actual variables?
> 
>   AMK4
> 

Ashley,

You don't really need to pass the values in your include.
All that include does is insert the file inine, as if it was written there.

So, leaving out the table=$table will still result in $table being defined
by the code prior to the include.

Ie.
$table="value or array or whatever"

Include("file that references $table.php");

// $table is still  in the global namespace, and the include file can
reference it as normal.

The only way you would need to pass values to the php file, like you did, is
if you were retrieving data from it through
fopen("http://domain.com/variables.php?table=$table",'r');

Include does not pre parse your file.

Hope that helps.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to