SunQuest
           PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old July 14th, 2002, 08:12 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
help with sorta simple code

im trying to find a way to take the current url's query info ( ex: www.page.org?page=news ) and put it in a variable, then include or write from a file named 'news.html' (or whatever the ?page= points to). ive been trying many ways and am currently having headaches because of it . if anything, can someone at least tell me how to get www.page.org?variable=var and have $a = the quearies variable? thanks ahead of time

Reply With Quote
  #2  
Old July 14th, 2002, 08:55 AM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: help with sorta simple code

go with the "parse_url" function to split up your uri, and then go from there

Reply With Quote
  #3  
Old July 14th, 2002, 09:21 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: help with sorta simple code

yeah i used parse_url before... and im not sure if it was right... it looked like this:
$page = parse_url($PHP_SELF)
$page = $page[query]

so then if the url looked like ?page=home it would theoretically make $page = home, right?
anyway then i did $page .= ".html" and include($page) and i dont think that worked... it should right? maybe i should try it again.

Reply With Quote
  #4  
Old July 14th, 2002, 09:27 AM
verylost verylost is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: southern california
Posts: 12 verylost User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to verylost
RE: help with sorta simple code

me again...

i just tried this code :

<?
if ($view === false) $view = "home"
$view .= ".html"
include($view)
?>

where the url would be www.page.org?view=home

it didnt work, i got "Parse error: parse error, unexpected T_VARIABLE"

would this method work, or should i stick with the parse_url. ill get back to you guys after trying parse again...

Reply With Quote
  #5  
Old July 14th, 2002, 09:49 AM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
RE: help with sorta simple code

You don't have any semicolons ( ; ) after your statements.. Did you copy & paste that block of code?

Change to :
php Code:
Original - php Code
  1.  
  2. <?
  3.   if ($view === false) $view = "home";
  4.   $view .= ".html";
  5.   include($view);
  6. ?>

And see what it does..

Reply With Quote
  #6  
Old July 14th, 2002, 12:47 PM
EvilivE EvilivE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Milwaukee, WI USA
Posts: 291 EvilivE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via Yahoo to EvilivE
RE: help with sorta simple code

Is it just me or am I missing something here? Would it not be easier just to do this:
php Code:
Original - php Code
  1.  
  2. if(!isset($_GET['view'])){
  3.   $view = "home.html";
  4. } else {
  5.   $view = $_GET['view']."html";
  6. }
  7.  
  8. include("any_path".$view);


Just an idear!

Reply With Quote
  #7  
Old July 14th, 2002, 01:43 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: help with sorta simple code

no, see $PHP_SELF won't return your uri variables.. you'll need to use $HTTP_SERVER_VARS[REQUEST_URI]

for example..
$uri = $HTTP_SERVER_VARS["REQUEST_URI"];
parse_url($uri);

or if you need the domain too, then use $HTTP_SERVER_VARS["HTTP_HOST"] and hook the two together such as..

$vars = $HTTP_SERVER_VARS["REQUEST_URI"];
$domain = $HTTP_SERVER_VARS["HTTP_HOST"];
$uri = "$vars$domain";
parse_url($uri);

err.. you might need the http://full-addy in there for the parse_url to work either way.. hope that helps..

Reply With Quote
  #8  
Old July 15th, 2002, 05:19 AM
verylost verylost is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: southern california
Posts: 12 verylost User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to verylost
RE: help with sorta simple code

evilive, thats actually what i wanted =D. i learn more everyday! oh and the code i put before did have semi's, i was just to lazy to put them into the post. right after i posted i remembered $PHP_self doesnt give the url... anyway, thanks alot. it was quite an easy script but i just couldnt get it for some reason, thanks evilive

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > help with sorta simple code


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway