Forum Moderators: coopster
<?
include("testconfig.php");
$var1 = "Arizona";
$var2 = "arizona";
$var3 = "Az";
$var4 = "az";
?>
A part of the page calls for a scroller which will be different for each page. The call for the scroller is:
<td width="150"><? include("$scroller");?></td>
In config.php I have the variables renamed:
$state = &$var1;
$statesmall = &$var2;
$stateabrev = &$var3;
$stateabrevsmall = &$var4;
Also in config.php I have:
$scroller = "scroller.az.php";
The file I want to call is scrolleraz.php or better yet;
/az/scroller.php
I want to insert the value of $stateabrevsmall into the filename which is called, I cannot seem to get it formated properly.
Depending on how I try to include the variable my error message changes!
If I just make $scroller = "scrolleraz.php" all is well but I am not using the opportunity for a different file to be assigned each different $var4.
I want to have the page built dynamically from the $vars.
Please help!
I have been pulling my hair out for 3 weeks, been through this forum a lot but do not see a like issue.
I have tried that, the error I get is:
Warning: main(): Failed opening '' for inclusion (include_path='.:/usr/local/lib/php') in /usr/www/users/success/USA/statebody.php on line 14
Yet when I just put $scroller = "scrolleraz.php";
it works.
the statebody file is as follows:
<?
?>
<div align="center">
<center>
<table border="1" cellpadding="1" width="90%" cellspacing="1">
<tr>
<td align="center" bgcolor="<?echo"$bgcolor1";?>">a</td>
</tr>
<tr>
<td align="center" width="576" colspan="3" bgcolor="<?echo"$bgcolor1";?>">b</td>
<td width="150"><? include("$scroller");?></td>
<td width="120" align="center">d</td>
</tr>
<td>e</td>
</table>
</center>
</div>
The main state page calls the statebody.php which calls the $scroller.
I have a feeling it is something simple I have forgotten but it works calling up the "simple version" of scroller.
Thanks for your help on this!
$scroller = "scroller" . $var4 . ".php";
...and then immediately follow it with this:
echo "$scroller";
...what do you see?
If you see "scrolleraz.php", then I'd have no idea why it doesn't work.. because theoretically it's the same thing as passing the actual text to the variable. If you see something else, like "scroller.php", that means that $var is being redefined at some point, or is out of scope.
It sounds like you've got a lot going on outside of the code that you have posted here.
As Nick has said, it looks like $var4 is either out of scope or has been redefined to be an empty string by the time you call include($scroller).
To debug this, I would start with a single PHP script of nothing more than as follows:
<?php$var4 = "zz";
$scroller = "scroller".$var4.".php";
include($scroller);
?>
In scrollerzz.php simply do:
<?phpecho("Hello, world!");
?>
Get that working to make sure the mechanics of what you are trying to do are all working OK on your setup / PHP configuration.
Then,go into your main script and start echoing $var4 at various points to see where it is going out of scope or is being reset.