 | [Solved] PHP help NR |  |
Posted: 06/23/2007 5:46 PM |
|
|
|
|
|
| Citation |
| Posts |
407 |
| Word Cnt. |
10,993 |
| BDay |
May 28 |
| Sign |
Gemini |
| Sex |
 |
|
|
|
Joined: Feb 25, 2007
Local time: 11:36 PM
Location: SE England
|

|
|
|
|
 |
Hi NR.
I'm coding my site, and I need help.
In index.php there is this code:
| Code:
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Insane-Mainframe</title>
<link href="index.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
switch ( isset ($HTTP_GET_VARS['id']) || isset($HTTP_POST_VARS['id']) )
{
//Default - case
default:
include"includes/pages/index/index.tpl";
break;
//Mails - case
case 'support':
include "includes/pages/mails/mails.tpl";
break;
//Links - case
case 'links':
include "includes/pages/links/links.tpl";
break;
}
?>
</body>
</html>
|
The Links part isn't working.
It's the 3rd item in the list that doesn't work; if it was moved up, it would work.
Help?
Thanks,
- Poomie |
|
|
 |
 |
| Back to Top |
|
|
 | Re: PHP help NR |  |
Posted: 06/23/2007 6:24 PM |
|
|
|
|
|
| Site Admin |
| Posts |
30757 |
| Word Cnt. |
2,628,690 |
| BDay |
Jul 28 |
| Sign |
Leo |
| Sex |
 |
|
|
|
Joined: Sep 25, 2004
Local time: 7:36 PM
Location: St Pete, FL
|

|
|
|
|
 |
The switch statement is completely backwards for starters. The default answer should come last, not first. So you might try rewriting it like this:
| Code:
|
switch ( isset ($HTTP_GET_VARS['id']) || isset($HTTP_POST_VARS['id']) )
{
case 'support': //Mails - case
include "includes/pages/mails/mails.tpl";
break;
case 'links': //Links - case
include "includes/pages/links/links.tpl";
break;
default: //Default - case
include"includes/pages/index/index.tpl";
break;
}
|
If that doesn't solve your problem, then you will want to take a look at the contents of the variables being passed to the switch. So you could do this next if necessary:
| Code:
|
$id1 = $HTTP_GET_VARS['id'];
$id2 = $HTTP_POST_VARS['id'];
echo '$id1 = ' . $id1 . '<br />';
echo '$id2 = ' . $id2 . '<br />';
switch ( isset($HTTP_GET_VARS['id']) || isset($HTTP_POST_VARS['id']) )
{
case 'support': //Mails - case
include "includes/pages/mails/mails.tpl";
break;
case 'links': //Links - case
include "includes/pages/links/links.tpl";
break;
default: //Default - case
include"includes/pages/index/index.tpl";
break;
}
|
To me, this switch statement can only return a true or false answer. But the switch is looking for a character value of 'support' or 'links', so it seems to me that the default will be the only possible outcome 100% of the time. So you might have to rewrite this something like this:
| Code:
|
$id1 = $HTTP_GET_VARS['id'];
$id2 = $HTTP_POST_VARS['id'];
echo '$id1 = ' . $id1 . '<br />';
echo '$id2 = ' . $id2 . '<br />';
$id3 = ( isset($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : ( isset($HTTP_GET_VARS['id']) ) ? $HTTP_GET_VARS['id'] : '';
switch ( $id3 )
{
case 'support': //Mails - case
include "includes/pages/mails/mails.tpl";
break;
case 'links': //Links - case
include "includes/pages/links/links.tpl";
break;
default: //Default - case
include"includes/pages/index/index.tpl";
break;
}
|
Once you are comfortable that this is working correctly, you can remove the following code since it is no longer necessary:
| Code:
|
$id1 = $HTTP_GET_VARS['id'];
$id2 = $HTTP_POST_VARS['id'];
echo '$id1 = ' . $id1 . '<br />';
echo '$id2 = ' . $id2 . '<br />';
|
 |
|
|
 |
 |
| Back to Top |
|
|
 | Re: [Solved] PHP help NR |  |
Posted: 06/24/2007 3:33 AM |
|
|
|
|
|
| Citation |
| Posts |
407 |
| Word Cnt. |
10,993 |
| BDay |
May 28 |
| Sign |
Gemini |
| Sex |
 |
|
|
|
Joined: Feb 25, 2007
Local time: 11:36 PM
Location: SE England
|

|
|
|
|
 |
I tried your last suggestion, and it worked fine
There wasn't a need for:
| Code:
|
echo '$id1 = ' . $id1 . '<br />';
echo '$id2 = ' . $id2 . '<br />';
|
because it was just echoing something like this:
$id1 = links
$id2 =
or
$id1 = support
$id2 =
Thanks,
- Poomie |
|
|
 |
 |
| Back to Top |
|
|
 | Re: PHP help NR |  |
Posted: 06/24/2007 4:05 AM |
|
|
|
|
|
| Site Admin |
| Posts |
30757 |
| Word Cnt. |
2,628,690 |
| BDay |
Jul 28 |
| Sign |
Leo |
| Sex |
 |
|
|
|
Joined: Sep 25, 2004
Local time: 7:36 PM
Location: St Pete, FL
|

|
|
|
|
 |
I knew that there wasn't a need for the echo statements, but I wanted you to see how you could see the contents of the variables so if you encounter a problem like this again, you will have an idea of what to try. Once you see the contents of the variables, it can help you determine why things are happening or not...
In this case, the switch statement was wrong in several ways, so the default option was the only one that could ever work since the other two options were not true or false selections. So the only place for the code to go was into the default. The isset function only returns true or false and not a string...
 |
|
|
 |
 |
| Back to Top |
|
|
 | Re: [Solved] PHP help NR |  |
Posted: 06/24/2007 8:19 AM |
|
|
|
|
|
| Citation |
| Posts |
407 |
| Word Cnt. |
10,993 |
| BDay |
May 28 |
| Sign |
Gemini |
| Sex |
 |
|
|
|
Joined: Feb 25, 2007
Local time: 11:36 PM
Location: SE England
|

|
|
|
|
 |
Yeah, I could definitely see how yours worked
- Poomie |
|
|
 |
 |
| Back to Top |
|
|
 | Re: PHP help NR |  |
Posted: 06/24/2007 4:30 PM |
|
|
|
|
|
| Site Admin |
| Posts |
30757 |
| Word Cnt. |
2,628,690 |
| BDay |
Jul 28 |
| Sign |
Leo |
| Sex |
 |
|
|
|
Joined: Sep 25, 2004
Local time: 7:36 PM
Location: St Pete, FL
|

|
|
|
|
 |
|
|
 |
 |
| Back to Top |
|
|
 | Re: [Solved] PHP help NR |  |
Posted: 06/25/2007 12:33 AM |
|
|
|
|
|
| Citation |
| Posts |
407 |
| Word Cnt. |
10,993 |
| BDay |
May 28 |
| Sign |
Gemini |
| Sex |
 |
|
|
|
Joined: Feb 25, 2007
Local time: 11:36 PM
Location: SE England
|

|
|
|
|
 |
So how you been lately?
Haven't spoken in a while
- Poomie |
|
|
 |
 |
| Back to Top |
|
|
 | Re: [Solved] PHP help NR |  |
Posted: 06/25/2007 2:09 PM |
|
|
|
|
|
| Site Admin |
| Posts |
30757 |
| Word Cnt. |
2,628,690 |
| BDay |
Jul 28 |
| Sign |
Leo |
| Sex |
 |
|
|
|
Joined: Sep 25, 2004
Local time: 7:36 PM
Location: St Pete, FL
|

|
|
|
|
 |
I'm still having a lot of bad days, but not as bad as the last several weeks. Hopefully things will continue to improve...
How are things going on your side of the pond???
 |
|
|
 |
 |
| Back to Top |
|
|
 | Re: [Solved] PHP help NR |  |
Posted: 06/26/2007 12:46 PM |
|
|
|
|
|
| Citation |
| Posts |
407 |
| Word Cnt. |
10,993 |
| BDay |
May 28 |
| Sign |
Gemini |
| Sex |
 |
|
|
|
Joined: Feb 25, 2007
Local time: 11:36 PM
Location: SE England
|

|
|
|
|
 |
Things are getting better and better
My hosting came through last week, Ubuntu has been running flawlessly, just got Photoshop CS2 and VB.NET ^^
The people on my site have been quite active 9 members, but with atleast 2 posts each, and about 502 posts between then.
Yay ^^
Hopefully things will be getting better and better for you too, mate
Best wishes,
- Poomie |
|
|
 |
 |
| Back to Top |
|
|
 | Re: [Solved] PHP help NR |  |
Posted: 06/27/2007 11:26 AM |
|
|
|
|
|
| Site Admin |
| Posts |
30757 |
| Word Cnt. |
2,628,690 |
| BDay |
Jul 28 |
| Sign |
Leo |
| Sex |
 |
|
|
|
Joined: Sep 25, 2004
Local time: 7:36 PM
Location: St Pete, FL
|

|
|
|
|
 |
That's awesome news. I think we started with about 8 regular members, so you're off to a good start. I hope your website continues to grow and thrive...
 |
|
|
 |
 |
| Back to Top |
|
|
 | Information |  |
Welcome to RCF - WHF Forum Index
-> Talk PC
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
All times are GMT - 5 Hours Goto page: 1, 2 Next Page 1 of 2
Add To Bookmarks
|
|
|
|
|