Reviews, updates and in depth guides to your favourite mobile games - AppGamer.com
|
|
PHP won't work correctly. |
Page: 1 2 | Reply |
Oct 30th 2004 | #162111 Report |
Member since: Jun 2nd 2004 Posts: 124 |
Ok I did this site for a client. I used PHP $id to bind the content when on the web. But the thing is it won't work correctly. Here is the site: http://www.bramiljø.no Now if you click on any links it will ONLY display the first site as usual. Here's the $id code: switch ($id) { case "1": include("innhold/1.php"); break; case "2": include("innhold/2.php"); break; case "3": include("innhold/3.php"); break; case "4": include("innhold/4.php"); break; case "5": include("innhold/5.php"); break; case "6": include("innhold/6.php"); break; case "7": include("innhold/7.php"); break; default: include("innhold/1.php"); } ?> Om oss Now I know that many might think the server don't support PHP, but then the first site wouldn't work either. I have checked that files are placed where they belong to. There's a possibility that it's the server, since I seem to make it work on mine but not their's. Any tips on this? |
Reply with Quote Reply |
Oct 30th 2004 | #162120 Report |
Member since: Oct 14th 2004 Posts: 7 |
remove the quotes around the case case 1 instead of case "1" |
Reply with Quote Reply |
Oct 31st 2004 | #162140 Report |
Member since: Oct 24th 2004 Posts: 62 |
Im not savy with php but in java switch statements go [PHP] switch(id) { case 1: blahblah; break; case 2: mahaha; break; } [/PHP] Take away your " & " marks but keep the : |
Reply with Quote Reply |
Oct 31st 2004 | #162161 Report |
Member since: Apr 20th 2002 Posts: 3000 |
Since you named your files like that, just do: [php]if ($id > 1 && $id <= 7) include('innhold/'.$id.'.php'); else include('innhold/1.php');[/php] |
Reply with Quote Reply |
Oct 31st 2004 | #162167 Report |
Member since: Oct 24th 2004 Posts: 62 |
[QUOTE=!mo0chan!]Since you named your files like that, just do: [php]if ($id > 1 && $id <= 7) include('innhold/'.$id.'.php'); else include('innhold/1.php');[/php][/QUOTE] Php's formating standards frighten me.... |
Reply with Quote Reply |
Oct 31st 2004 | #162169 Report |
Member since: Apr 20th 2002 Posts: 3000 |
Technically, it should be written like this: [php]if ($id > 1 && $id <= 7) { include('innhold/'.$id.'.php'); } else { include('innhold/1.php'); }[/php] but I prefer to shorthand it. :p |
Reply with Quote Reply |
Nov 1st 2004 | #162187 Report |
Member since: Oct 24th 2004 Posts: 62 |
Its not the absence of {}, it was how u put it all on 2 lines. *shudders*
|
Reply with Quote Reply |
Nov 1st 2004 | #162190 Report |
Member since: Apr 20th 2002 Posts: 3000 |
Why do you find it frightening? o_O;
|
Reply with Quote Reply |
Nov 1st 2004 | #162196 Report |
Member since: Oct 24th 2004 Posts: 62 |
Im in an AP java class, we normally dont take the extreme quickies when writing code.
|
Reply with Quote Reply |
Nov 1st 2004 | #162202 Report |
Member since: Jun 2nd 2004 Posts: 124 |
Hmm, well the thing is, why does this work on my server, but he's server can only display the first php include?
|
Reply with Quote Reply |
Page: 1 2 | Back to top |
Please login or register above to post in this forum |
© Web Media Network Limited. All rights reserved. No part of this website may be reproduced without written permission. Photoshop is a registered trademark of Adobe Inc.. TeamPhotoshop.com is not associated in any way with Adobe, nor is an offical Photoshop website. |