P.Z. Low Cost CPanel Web Hosting  

Go Back   P.Z. Low Cost CPanel Web Hosting > Page-Zone Web Hosting Main Forum > General Discussion

General Discussion Anything which doesn't fit into the specific topics above. Posting limited to registered members.

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
PHP Variable problem.
Old
  (#1 (permalink))
pdgradio
Registered User
pdgradio is on a distinguished road
 
Status: Offline
Posts: 7
Join Date: Feb 2006
Rep Power: 0
PHP Variable problem. - 02-05-2006, 11:05 AM

hey all,

** I am fairly new to the whole php thing. **

I had some code that used to work on my old host, but doesn't now. This code is for if i wanted to type in something like content.php?page=logs and have it show /logs.php in an iframe further down the page. (check out http://rb.pdgradio.com for an example).

Quote:
<?php
if($page=="home") {
$page = "/home.php";
} else if($page=="bios") {
$page = "bios.php";
} else if($page=="logs") {
$page = "/logs.php";
} else if($page=="guests") {
$page = "/guests.php";
} else if($page=="affiliates") {
$page = "/affiliates.php";
} else if($page=="contact") {
$page = "/contact.php";
} else $page = "/home.php";
?>
(HTML Part)
Quote:
<iframe
name="contentFrame"
src="<? echo($page); ?>"
height="316"
width="347"
frameborder="0"
marginheight="0"
marginwidth="0"
scrolling="auto"
allowtransparency="1">
</iframe>
My problem is that no matter that i type in the Address bar, $page will always result in "/home.php."
In fact, clearning all that code and putting the following still fails:

Quote:
string entered in url is "test.php?word=foo"

<?php
$word="";
//this following should display "Foo"?? It doesn't.
echo ($word);
?>


any ideas on how to get it to pass the variable from the url?

thanks in advance!!!
   
Reply With Quote
Old
  (#2 (permalink))
pdgradio
Registered User
pdgradio is on a distinguished road
 
Status: Offline
Posts: 7
Join Date: Feb 2006
Rep Power: 0
02-05-2006, 05:17 PM

Hey all,

After a little extensive research, I fixed my own issue.

For those who also might want to know the resolve...here it is...

Quote:
<?php
// Var's for arguments given.
$pid = $_GET["page"];
$lid = "blog_id=".$_GET["log"];


if($pid=="home") {
$url = "/home.php";
} else if($pid=="bios") {
$url = "bios.php";
} else if($pid=="logs") {
$url = "/logs.php?".$lid;
} else if($pid=="guests") {
$url = "/guests.php";
} else if($pid=="affiliates") {
$url = "/affiliates.php";
} else if($pid=="contact") {
$url = "/contact.php";
} else $url = "/home.php";
?>
and I use $url to call the final link for my iframe.

Hope this can help others.
   
Reply With Quote
Old
  (#3 (permalink))
midwest
blink and it's over
midwest will become famous soon enough
 
midwest's Avatar
 
Status: Offline
Posts: 802
Join Date: Oct 2002
Location: Big Sky, MT
Rep Power: 78
02-05-2006, 07:09 PM

Unless Im missing something why go through all that code

$url = "/$pid.php";


Ronnie Gauthier
www.instaguide.com

======================
for official page-zone support please visit
www.page-zone.com/support.shtml
   
Reply With Quote
Old
  (#4 (permalink))
pdgradio
Registered User
pdgradio is on a distinguished road
 
Status: Offline
Posts: 7
Join Date: Feb 2006
Rep Power: 0
02-05-2006, 07:17 PM

to prevent 404's and such. Other than that, im only guessing
   
Reply With Quote
Old
  (#5 (permalink))
midwest
blink and it's over
midwest will become famous soon enough
 
midwest's Avatar
 
Status: Offline
Posts: 802
Join Date: Oct 2002
Location: Big Sky, MT
Rep Power: 78
02-05-2006, 07:23 PM

if ($pid=="")
{$url="/home.php";}
else
{$url="/$pid.php";}

One p[roblem I see is if you wnat ot add a page
foo.php you need to alter your code or get a 404. My way you never have to alter your code you just build a link with ?page=foo


Ronnie Gauthier
www.instaguide.com

======================
for official page-zone support please visit
www.page-zone.com/support.shtml
   
Reply With Quote
Old
  (#6 (permalink))
pdgradio
Registered User
pdgradio is on a distinguished road
 
Status: Offline
Posts: 7
Join Date: Feb 2006
Rep Power: 0
02-08-2006, 02:03 PM

kewl, thank you for that
   
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Live Help



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC6
vBulletin Skin developed by: vBStyles.com
Copyright © 2002 Page-Zone Web Hosting. All rights reserved.
Smilies provided by Crack's Smilies http://www.mysmilies.com