I have a relatively trivial problem that's driving me up a wall. I've tracked it down to a specific character - / - , and I still can't solve it! I think it's a relatively simple problem, though my explanation is a bit lengthy.

I'm working on a site with pages for each of the 50 states that uses PHP includes and echo statements. The problem seems to derive from one of four types off pages:

1. The head section on each main page
2. A single included page that's inserted in each head section
3. another included page (state/top) inserted in each page
4. A series of style sheets specific to state regions (north, south, etc.).

Below is a snippet of code from the page that's included in the head:

echo '<link href="' . $periods . 'css/' . $continentcode . '/' . $myregion . '.css" rel="stylesheet" type="text/css" />';

In the main page, three echo values are used to form links to style sheets:

' . $periods . ' is replaced with ../../../../,
' . $continentcode . ' is replaced by na (for North America)
' . $mycode . ' is replaced by each state's postal code (ak, wa, etc.)

This is an example of a style sheet URL they form:

<link href="../../../../css/na//north.css" rel="stylesheet" type="text/css" />

Below is a copy of a main page's head section, which ends with the include:

<head>
<?php
$myname = 'Alaska';
$mynickname = 'Land of the Midnight Sun';
$mycode = 'ak';
$myregion = 'north';
$mycountry = 'United States';
$mycontinent = 'North America';
$countrycode = 'us';
$continentcode = 'na/';
$periods = '../../../../';
$linkwebring = '/world/na/us/ak/';
$includea1 = TRUE;
include ("../../../../includes/state/head.php");
?>
</head>

Below are the URLs of the head include, the top include I'll mention next, an example of a state page (Alaska) and an example of a regional style sheet (the North):

http://www.freedomware.us/includes/state/head.php
http://www.freedomware.us/includes/state/top.php
http://www.freedomware.us/world/na/us/ak/
http://www.freedomware.us/css/na/north.css

This is all the code from a top include. Just skim to the the lat few lines, where it says "banner":

<?php
$todayDate = date("m-d-Y");
echo '<div class="toplinks" id="tl' . $mycode . '"><a href="../../../../index.php">Freedomware</a> &gt; <a href="../../../index.php">World</a> &gt; <a href="../../index.php">' . $mycontinent . '
</a> &gt; <a href="../index.php">' . $mycountry . '</a> &gt; <span class="navhere">' . $myname . '</span></div>';
echo '<div class="layertop" id="lt' . $mycode . '">
<div class="title id="title' . $mycode . '">' . $myname . '</div>
<div class="titlegroup" id="tgroup' . $mycode . '">
<span class="subtitle" id="sub' . $mycode . '">' . $mynickname . '</span>
<div class="quote2" id="q2' . $mycode . '">
<div class="quote" id="q' . $mycode . '">&#8220;There are two lasting bequests we can give our
children: One is roots. The other is wings.&#8221;</div>
<span class="sig" id="sig' . $mycode . '">Hodding Carter, Jr.</span></div>
</div>
</div>';
echo '<div class="banner" id="ban' . $mycode . '"><img id="bannerimage" src="../../../../images/spacer.gif" width="300" height="50" alt="Top Banner" /></div>';
echo '<div class="pagesymbol" id="ps' . $mycode . '"><img src="../../../../images/spacer.gif" width="200" height="150" alt="" /></div>'
?>


"banner" is a layer (div) with an invisible spacer image. It is replaced by various background images defined by the regional style sheets.

Below is all the text from one regional style sheet, North:

/* CSS: Freedomware > CSS > NA > NORTH (The Far North) */

div#title { color: #009; }
#subak { background: #009; color: #ff0; }
td#tdcenter { background: #fff; }
h1 { background: #009; color: #fff; }

div#banak { background: url(../../../images/banners/na/ak.gif) no-repeat 50% 0; }
div#bannt { background: url(../../../images/banners/na/nt.gif) no-repeat 50% 0; }
div#bannu { background: url(../../../images/banners/na/nu.gif) no-repeat 50% 0; }
div#banyt { background: url(../../images/banners/na/yt.gif) no-repeat 50% 0; }
.subtitle { color: #009; border-top: 1px solid #009; border-bottom: 1px solid #009; }



Notice that this code from the top include:


echo '<div class="banner" id="ban' . $mycode . '">

id converted from id="ban" + $mycode to id="banak" (Alaska), id="banyt" (Yukon Territory), etc.

So here's the problem. The top banners don't show up on some pages unless I add the character / to the head section. An example is Alaska, which requires a / before "north":

$mycode = 'ak';
$mywebring = '/world/na/us/ak/';
$myregion = '/north';

But the head section for Yukon Territory works the way it's supposed to, with no / before north:

$mycode = 'yt';
$mywebring = '/world/na/us/ak/';
$myregion = 'north';

All three states linked to the Pacific Northwest top include won't work without the extra / - Washington, Oregon and the province of British Columbia, illustrated below:

$mycode = 'bc';
$mywebring = '/world/na/can/bc/';
$myregion = '/pnw';

Another weird example is Idaho, which appears to work as it should online, but I can't see the top banner on my local site unless I add the /.

Also, I don't necessarily have to add a / before the continent code; I've also fixed it by adding a / to the state postal code ("mycode").

I thought the problem could be traced to this snippet from my head include, specifically to the code between continent code and my region - '/'.

echo '<link href="' . $periods . 'css/' . $continentcode . '/' . $myregion . '.css" rel="stylesheet" type="text/css" />';

That particular / should be included in every style sheet URL. By adding an extra url before "north" in Alaska's head section, my URL should wind up with two forward slashes - css/na//ak.css Yet I only see one when I view the source code.

Thanks in advance to any tips, as I may be gone for most of the day.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to