Page 1 of 1
PHP Works in Some Parts of a Page, But Not Others?
Posted: Thu Jul 23, 2009 9:41 am
by dsmith21212
I have this line of code in header.php which allows a website owner to specify a color scheme through a configuration file.
Code: Select all
<link rel="stylesheet" type="text/css" href="<?php echo $cbvurl ?>styles/<?php echo $cbvstyle ?>.css" />
I'm running into two problems.
1. In most pages, the style displays properly. In others, no style at all.
View Source shows this:
Code: Select all
<link rel="stylesheet" type="text/css" href="styles/.css" />
2. On pages where this does
not work,
does work in other parts of the same page (main menu). (strange = in some parts of the site, this tag needs a trailing slash, but not in others...)
All pages have the .php file extension and headers are called by include statement. (XAMPP)
Re: PHP Works in Some Parts of a Page, But Not Others?
Posted: Sat Jul 25, 2009 10:42 am
by cpetercarter
If the source code reads :
Code: Select all
<link rel="stylesheet" type="text/css" href="styles/.css" />
then obviously the script is unable to find values for $cbvurl and $cbvstyle.
You will need to go through the logic of your code carefully to find out why. Perhaps the code which defines $cbvurl and $cbvstyle runs after the code which writes the head section of the web page. Or perhaps the two variables have limited scope (eg they exist within a function, but not outside it).