PDA

View Full Version : php variables


pmm19518
01-22-2005, 06:06 PM
Hi All,

I have a small php script (copied at end of this message) that I've put in my www shortcut folder. It basically calls the css and is just not working.

When I phpinfo(), I don't see the variable I called - $HTTP_GET_VARS["cssfile"]

Is the file in the wrong folder? Do I have wrong permissions on the www folder?
Any help is appreciated,
-Patricia
script:
$tempCSS = $HTTP_GET_VARS["style1.css"];
if ($tempCSS != "") {
$loadCSS = $tempCSS;
} else {
/* sets a default CSS file if no querystring specified now */
$loadCSS = "style1.css";
};
$currentDesign = $loadCSS;

Silmaril8n
01-22-2005, 06:56 PM
PHP only sets the variable at runtime while the script is working. You would have to have that at the top of every PHP file in your website for it to work.

You could also do something like that with sessions or cookies I suppose.

pmm19518
01-22-2005, 10:17 PM
Thanks for the reply. I'm a newbie and reallly appreciate the help.

Right now, I only have one file (index.html) on my site.

Do I place the php code in the index.html file or do I place it in its own little .php file in the same folder?

-Patricia

SnakEyez
01-22-2005, 10:26 PM
You could do one of two things. You could either put it in your index file. Or create a separate file and just include it at the top of the index and any other pages you may want to use it on down the road.

Also just a word of advice to improve your script. Don't use the HTTP_*_VARS. The newer versions of PHP are not turning on long vars by default much the same as the register_globals function. So it would probably be better to get used to using the new functions like $_GET and $_POST. This way you can be sure that your script will continue to work as PHP is upgraded.

pmm19518
01-22-2005, 10:37 PM
Thanks SnakEyez,

I did add the php code to my index.html file, however it is being ignored.

Do I have to edit some apache config file (.htaccess) to get the server to parse php? If yes, how and where?

Thanks again,
-Patricia

RammsteinNicCag
01-23-2005, 12:14 AM
You can either rename index.html to index.php so it is automatically parsed or you can add this to your .htaccess file:

AddType application/x-httpd-php .htm .html .php

Jennifer