PCTechTalkhttp://www.pctechtalk.com/forums/

Go Back   PCTechTalk > PC Tech > Web Related

Reply
 
LinkBack Thread Tools Display Modes
Old 02-12-2004, 07:01 PM   #1 (permalink)
Registered User
 
Colin-uk's Avatar
 
Join Date: Jan 2003
Location: UK
Posts: 928
Colin-uk is on a distinguished road
Another php script problem

hi all,

im trying to get this 'navigation' script working
here is the code im using: (this goes in index.php)

PHP Code:
<?php

switch ($skin)
{
case 
"Seablue":
include(
'/skins/seablue/index.php');
break;
case 
"Plainpurple":
include(
'/skins/plainpurple/index.php');
break;
case 
"forestgreen":
include(
'/skins/forestgreen/index.php');
break;
case 
"Midnightblack":
include(
'/skins/midnightblack/index.php');
break;
default:
include(
'/skins/seablue/index.php');
}

?>
and i call each page with the following:

Quote:
index.php?skin=seablue
but all it does is reload the page

i cant see what im doing wrong as everything seems to be right...

any help appreciated *cough*greffov*cough*
thanks
Colin-uk is offline   Reply With Quote
Old 02-13-2004, 03:06 AM   #2 (permalink)
Da House Nerd
 
greffov's Avatar
 
Join Date: Dec 1969
Location: One CPU Lane
Posts: 3,512
greffov will become famous soon enough
well, first, discarding what goes really wrong here, your default is seablue, and you want to change the theme to seablue... heh, not weird nothing changes, eh?

Then, PHP is case sensitive, giving you the major problem that 'Seablue' does not equal 'seablue'...

There are a number of ways to solve that problem:
1. just use lowercase everywhere (default UNIX behaviour)
2. lowercase your input first, then use a switch with only lowecase cases
3. convert your switch into an if/else statement, where you use PHP's case insensitive string comparisation functions to do find out what you want.

It may be clear that the last solution is not only more work, but also more inefficient. If you expect people to enter the name themselves, go for 2. I expect however that you will generate the theme names yourself in some script in the end, thus you best go for option 1.

(UNIX roxx)
__________________
Linux virusscanner detected a virus:
Windows 95 ... delete [Y/n] y
~
~

:wq
greffov is offline   Reply With Quote
Old 02-13-2004, 05:00 AM   #3 (permalink)
Registered User
 
Colin-uk's Avatar
 
Join Date: Jan 2003
Location: UK
Posts: 928
Colin-uk is on a distinguished road
ok so i put everything lowercase and tried loading a diffrent theme

still gettin the same...
Colin-uk is offline   Reply With Quote
Old 02-13-2004, 10:36 AM   #4 (permalink)
Da House Nerd
 
greffov's Avatar
 
Join Date: Dec 1969
Location: One CPU Lane
Posts: 3,512
greffov will become famous soon enough
your site has register globals switched on?

you sure the switch works like you expect it to? (the strings could be your problem IN the switch cases... have you trie replacing the includes by echo commands?)
__________________
Linux virusscanner detected a virus:
Windows 95 ... delete [Y/n] y
~
~

:wq
greffov is offline   Reply With Quote
Old 02-14-2004, 11:53 AM   #5 (permalink)
Registered User
 
Colin-uk's Avatar
 
Join Date: Jan 2003
Location: UK
Posts: 928
Colin-uk is on a distinguished road
thanks for the help greffov

i found the problem was that i was testing on my local machine..
i uploaded to my host and it all worked fine

Although i do have apache server, php4 and mysql all installed so thats why i thought it was a script problem lol
Colin-uk is offline   Reply With Quote
Old 02-14-2004, 11:59 AM   #6 (permalink)
Da House Nerd
 
greffov's Avatar
 
Join Date: Dec 1969
Location: One CPU Lane
Posts: 3,512
greffov will become famous soon enough
ah, then most probably your local installation had register_globals = Off in the php.ini file.
__________________
Linux virusscanner detected a virus:
Windows 95 ... delete [Y/n] y
~
~

:wq
greffov is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -5. The time now is 08:02 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
2001 PCTechTalk