Forum Moderators: coopster
Include.php
$lin = mysql_query("SELECT * FROM link order by id asc", $link) or die ("query 1: " . mysql_error());
echo '<li><h2>LinkWork</h2>'
. '<ul>';
while ($li = mysql_fetch_array($lin)) {
if ($current == $li['base'])
{
echo '';
}
else
{
echo '<li><a href="'.$li['web_url'].'" alt="'.$li['alt_tag'].'">'.$li['display'].'</a></li>';
}
}
Including file
<?php
$current = 'bluewidget';
include("include.php");?>
This is on a wordpress blog if that helps.
Thanks
inctest.php
<?
$current = 'bluewidget';
include("include.php");
?>
include.php
<?
if (isset($current)) echo '<p>current is set';
else echo '<p>current is not set';
if (!empty($current)) echo '<p>current is not empty';
else echo '<p>current is empty';
echo '<p>the value of current is: ',$current;
?>
output
current is set
current is not empty
the value of current is: bluewidget
so it works fine for me, something else must be going on
included code doesn't change scope so you can get at anything which is accessible in the present scope
I could be completely wrong about this with PHP though.
But if so...perhaps there is a way for the other sites to grant permission by URL.
I have an include file at bluewidget.com, and I want to include it on bluewidget.com, #*$!, pinkwidget.com.
now the variable needed in my file is found on each of these sites.
<?php
$blue_var = 'text';
include 'http://www.bluewidget.com/file.php';
?>
that variable doesn't seem to pass.
When I insert it into my file on bluewidget.com like this
<?php
$blue_var = 'text';
include 'file.php';
?>
It works fine, but that won't work on pinkwidget.com.
I'm so confused.
Thanks
[php.net...]
If "URL fopen wrappers" are enabled in PHP (which they are in the default configuration), you can specify the file to be included using a URL (via HTTP or other supported wrapper - see Appendix N, List of Supported Protocols/Wrappers for a list of protocols) instead of a local pathname. If the target server interprets the target file as PHP code, variables may be passed to the included file using a URL request string as used with HTTP GET. This is not strictly speaking the same thing as including the file and having it inherit the parent file's variable scope; the script is actually being run on the remote server and the result is then being included into the local script.