tags:

views:

338

answers:

4

Here is the code from my style.php script The objective: User should be able to select and input different options for the background color and font.

This code snippet with css and php is called stlye.php and is suppose to supply the variables to be used on my outputform.php script.

<?php header("Content-type: text/css"); 
$gray = "#333";
$dkgreen = "#008400";
?>
body {
background:<?=$gray?>;
color:<?=$dkgreen?>;
}

Here is part of the php script from outputform.php:

<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>
Your Output
</title>
<link rel="stylesheet" type="text/css"
 media="screen" href="style.php">

I am pretty sure that by using href="style.php" I should be able to see the default colors coming from style.php above:$dkgreen for font color and $gray for background being displayed on outputform.php;however, this is not the case.

What am I doing wrong, or what do I need to read to fix this?

Overall objective is to get the CSS variables to outputform.php where I can manipulate them...give the user options to choose the font color and background color.

It's 5:51AM and Google info is overwhelming and does not want to play nice with me, either that or I need to get sleep.

if ($tired == sleep)
{
 print "get more coffee";
}
else
{
print "code badly...yeah, I am going to sleep now...................";
}
+3  A: 

Try putting a query string after style.css in the link tag.

<link rel="stylesheet" type="text/css"
 media="screen" href="style.php?v=1234">
Daniel A. White
explain why you think this will help
Ewan Todd
@Ewan Todd: It prevents the loading of any cached previous edits you may have made because the URL to the CSS file is different.
Nathan Kleyn
@Ewan Todd: browsers don't expect CSS to change often, they usually cache them pretty aggressively
Kip
In the quest to find solutions to coding problems, I think all answers should be welcome, until the problem is solved, what does not hurt, will only server to help, thanks.
Newb
+4  A: 

Try switching the echo tags with standard opening tags with the echo construct; you may find the short hand echo tag is not enabled thanks to the short_open_tag setting

background:<?php echo $gray; ?>;
color:<?php echo $dkgreen; ?>;
Nathan Kleyn
Sweetness:body { background:<?php echo $gray?>; color:<?php echo $dkgreen?>;}This worked, thanks Nathan Kleyn, and the link to short_open_tag setting, I just bookmarked that's some good php reading.
Newb
+1  A: 

You could try changing the content-type header. Set this at the beginning of style.php:

header('Content-type: text/css');
Kip
Actually I had prior issues with the header, I had single quotes in there, but I switched it to this:<?php header("Content-type: text/css"); before I started having issues with the CSS; however, that problem has been solved thanks to the help of all you wonderful guys and gals that take their time to help, with specific reference to Nathan Kleyn.
Newb
+1  A: 

is it a cache problem?

Load style.php by hand ie. http://yoursite.com/style.php, if it is valid css it's a cache problem. You can solve it by calling:

href="style.php?a=<?=microtime()?">

is it a css/php problem?

If you load style.php and it does not work or outputs something weird then you have a different problem and a different fix. Always try to break big things into tiny blocks when you're out problem hunting.

Hope you have a nice sleep! ;)

Frankie
Thanks, I like the notion of breaking up big things into tiny blocks when [I am] out problem hunting.That's why I try to post code snippets of where the actual problem might be as opposed to posting pages and pages of other code that is related to the problem but will not help solve the problem.
Newb