Log in Register FAQ Memberlist Search Welcome to RCF - WHF Forum Index
alt : test.swf
Welcome to RCF - WHF
4fx3.gif 
calendar_open_closeCalendar 
[Solved] PHP help NR
Post new topic   Reply to topic View previous topic :: View next topic
Goto page: 1, 2  Next
Welcome to RCF - WHF Forum Index -> Talk PC Add To Bookmarks
[Solved] PHP help NR
PostPosted: 06/23/2007 5:46 PM Reply with quote
Citation
poomerio
Citation
Posts 407
Word Cnt. 10,993
BDay May 28
Sign Gemini
Sex Sex:Male
Joined: Feb 25, 2007
Local time: 11:36 PM
Location: SE England
greatbrE.gif
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
View user's profile Find all posts by poomerio Send private message   Phoogle Map
Re: PHP help NR
PostPosted: 06/23/2007 6:24 PM Reply with quote
Site Admin
Nightrider
Site Admin
Posts 30757
Word Cnt. 2,628,690
BDay Jul 28
Sign Leo
Sex Sex:Male
Joined: Sep 25, 2004
Local time: 7:36 PM
Location: St Pete, FL
peace.gif
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 />';

headbang
Back to Top
View all pictures posted by this userView user's profile Find all posts by Nightrider Send private message   AIM Address Yahoo Messenger Phoogle Map ICQ Number
Re: [Solved] PHP help NR
PostPosted: 06/24/2007 3:33 AM Reply with quote
Citation
poomerio
Citation
Posts 407
Word Cnt. 10,993
BDay May 28
Sign Gemini
Sex Sex:Male
Joined: Feb 25, 2007
Local time: 11:36 PM
Location: SE England
greatbrE.gif
I tried your last suggestion, and it worked fine Smile
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
View user's profile Find all posts by poomerio Send private message   Phoogle Map
Re: PHP help NR
PostPosted: 06/24/2007 4:05 AM Reply with quote
Site Admin
Nightrider
Site Admin
Posts 30757
Word Cnt. 2,628,690
BDay Jul 28
Sign Leo
Sex Sex:Male
Joined: Sep 25, 2004
Local time: 7:36 PM
Location: St Pete, FL
peace.gif
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...

munky2
Back to Top
View all pictures posted by this userView user's profile Find all posts by Nightrider Send private message   AIM Address Yahoo Messenger Phoogle Map ICQ Number
Re: [Solved] PHP help NR
PostPosted: 06/24/2007 8:19 AM Reply with quote
Citation
poomerio
Citation
Posts 407
Word Cnt. 10,993
BDay May 28
Sign Gemini
Sex Sex:Male
Joined: Feb 25, 2007
Local time: 11:36 PM
Location: SE England
greatbrE.gif
Yeah, I could definitely see how yours worked Smile

- Poomie
Back to Top
View user's profile Find all posts by poomerio Send private message   Phoogle Map
Re: PHP help NR
PostPosted: 06/24/2007 4:30 PM Reply with quote
Site Admin
Nightrider
Site Admin
Posts 30757
Word Cnt. 2,628,690
BDay Jul 28
Sign Leo
Sex Sex:Male
Joined: Sep 25, 2004
Local time: 7:36 PM
Location: St Pete, FL
peace.gif
banana  banana  banana  banana  banana
Back to Top
View all pictures posted by this userView user's profile Find all posts by Nightrider Send private message   AIM Address Yahoo Messenger Phoogle Map ICQ Number
Re: [Solved] PHP help NR
PostPosted: 06/25/2007 12:33 AM Reply with quote
Citation
poomerio
Citation
Posts 407
Word Cnt. 10,993
BDay May 28
Sign Gemini
Sex Sex:Male
Joined: Feb 25, 2007
Local time: 11:36 PM
Location: SE England
greatbrE.gif
So how you been lately?
Haven't spoken in a while Smile

- Poomie
Back to Top
View user's profile Find all posts by poomerio Send private message   Phoogle Map
Re: [Solved] PHP help NR
PostPosted: 06/25/2007 2:09 PM Reply with quote
Site Admin
Nightrider
Site Admin
Posts 30757
Word Cnt. 2,628,690
BDay Jul 28
Sign Leo
Sex Sex:Male
Joined: Sep 25, 2004
Local time: 7:36 PM
Location: St Pete, FL
peace.gif
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???

dontknow
Back to Top
View all pictures posted by this userView user's profile Find all posts by Nightrider Send private message   AIM Address Yahoo Messenger Phoogle Map ICQ Number
Re: [Solved] PHP help NR
PostPosted: 06/26/2007 12:46 PM Reply with quote
Citation
poomerio
Citation
Posts 407
Word Cnt. 10,993
BDay May 28
Sign Gemini
Sex Sex:Male
Joined: Feb 25, 2007
Local time: 11:36 PM
Location: SE England
greatbrE.gif
Things are getting better and better Very Happy
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 Smile 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 Wink

Best wishes,
- Poomie
Back to Top
View user's profile Find all posts by poomerio Send private message   Phoogle Map
Re: [Solved] PHP help NR
PostPosted: 06/27/2007 11:26 AM Reply with quote
Site Admin
Nightrider
Site Admin
Posts 30757
Word Cnt. 2,628,690
BDay Jul 28
Sign Leo
Sex Sex:Male
Joined: Sep 25, 2004
Local time: 7:36 PM
Location: St Pete, FL
peace.gif
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...

Applause  Applause  Applause  Applause  Applause
Back to Top
View all pictures posted by this userView user's profile Find all posts by Nightrider Send private message   AIM Address Yahoo Messenger Phoogle Map ICQ Number
 Post new topic  Reply to topic
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

 
  
  


  Google

Powered by phpBB © 2001, 2005 phpBB Group

Page generation time: 0.0671s (PHP: 79% - SQL: 21%) - SQL queries: 57 - GZIP disabled - Debug on