Click to See Complete Forum and Search --> : PHP Style Switcher
davidbrent
05-15-2004, 07:35 AM
Hello Everybody.
I am setting up a PHP style switcher and i have been trying to use the A List Apart switcher. Unfortunatley i have encountered a problem and i cannot see any way to resolve it.
I recieve:
Parse error: parse error in /home/xxxx/public_html/mydirectory/switcher.php on line 3
Does anybody have any ideas? I am 97% sure i have installed it correctly. Otherwise does anybody have any other reccomendations for a different style switcher and the lcoation i can retrieve the script.
Best Wishes,
David
What does the code look like? Just the first 5 lines or so...
davidbrent
05-15-2004, 08:39 AM
Thanks for your reply.
The origingal code that i am using is the "switcher.php"
<?php
setcookie ('sitestyle', $set, time()+31536000, »
'/', 'mydomain.com', '0');
header("Location: $HTTP_REFERER");
?>
I keep on recieving the error when using the form to change styles. Here is the form.
<form action="switcher.php" method="post">
<select name="set">
<option value="default"> » selected</option>
<option value="red">Crazy Red</option>
<option value="experiment"> » Ex Style</option>
</select>
<input type="submit" value="Change Style">
</form>
Best Wishes,
David
The » is simply there to denote an editorial line wrap. Try this:
<?php
setcookie ('sitestyle', $_POST['set'], time()+31536000, '/', 'mydomain.com', '0');
header("Location: ".$_SERVER['HTTP_REFERER']);
?>
I also fixed it so it will work without global variables being enabled.
davidbrent
05-15-2004, 08:52 AM
Thanks Ryan.
Where it says "mydomain.com" do i put the directory where my style sheets are located?
And also within the form where it says 'Value="red"' would i change that to my stylesheet name?
EDIT: Oh and also, Would i have to have the standard
<link rel="stylesheet" type="text/css" media="screen" href="/css/one.css" />
as well as the alternative stylesheet tags?
Best Wishes,
David
Originally posted by davidbrent
Where it says "mydomain.com" do i put the directory where my style sheets are located?
No, that is what gives access to certain domains. Just put in "yoursite.com" there, if you add the directory name, the cookie will only exist if the current document is in the stylesheets directory.
Originally posted by davidbrent
And also within the form where it says 'Value="red"' would i change that to my stylesheet name?
Yes.
Originally posted by davidbrent
EDIT: Oh and also, Would i have to have the standard
<link rel="stylesheet" type="text/css" media="screen" href="/css/one.css" />
as well as the alternative stylesheet tags?
It would be a good idea to, unless you have the form on every page. That way users with good browsers (http://www.mozilla.org/) won't have to go to the style switching page to change the stylesheet - save time and bandwidth. ;)
davidbrent
05-16-2004, 10:31 AM
Thanks very much Jona.
I will try these later.
Best Wishes,
David