Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Cant Get A Script To Work, PHP
Florisjuh
post Sep 12 2005, 02:58 PM
Post #1


Proud to be hosted
*********

Group: Members
Posts: 993
Joined: 11-July 04
From: NL
Member No.: 75



I've been trying to get my website urls to work with an variable in the url to navigate. The script I use is:
CODE
 <?php
 switch ($page) {
 case "home":
  include home.php;
  break;
 case "members":
  include members.php;
  break;
 case "diplomacy":
  include diplomacy.php;
  break;
 case "scrims":
  include scrims.php;
  break;
 case "forums":
  include forums.php;
  break;
 default:
  include home.php;
  break;
 }
;?>

And I specify the hyperlinks as index.php?page=home etc
But it doesnt work, am I doing something rong in this script?
Go to the top of the page
 
+Quote Post
electriic ink
post Sep 12 2005, 03:05 PM
Post #2


Incest is a game the whole family can play.
Group Icon

Group: [MODERATOR]
Posts: 1,227
Joined: 11-February 05
From: Heaven
Member No.: 3,709



Don't understand half the script, but the first thing I would do is put speech marks or apostrophes round the include statements. Eg:

CODE
include bla.php;


Becomes.....

CODE
include "bla.php";


What kind of error do you get?
Go to the top of the page
 
+Quote Post
Microsoft
post Sep 12 2005, 08:10 PM
Post #3


Super Member
*********

Group: Members
Posts: 362
Joined: 25-August 05
Member No.: 11,104



i use a little bit of php and lots of html, html is so much easier for stuff. so i use html for mostly all of the stuff including the navigation. i know hardly anything about php i might learn it one day but not sure. Is using php better or something?

Notice from BuffaloHELP:
Do not go off topic.


This post has been edited by BuffaloHELP: Sep 12 2005, 08:36 PM
Go to the top of the page
 
+Quote Post
thablkpanda
post Sep 12 2005, 08:57 PM
Post #4


Super Member
*********

Group: Members
Posts: 339
Joined: 2-December 04
From: Atlanta, GA
Member No.: 2,516



Ah! Exactly what I was trying to do a few weeks ago-

You have to use the 'get' function to get the URL in the address bar first-

I don't remember how to do it exactly, but browse the PHP programming section.

That's the 'crucial' part you're missing. But on the other hand, good work with the cases- just won't work here biggrin.gif

Panda
Go to the top of the page
 
+Quote Post
SystemWisdom
post Sep 13 2005, 02:42 AM
Post #5


Advanced Member
*******

Group: Members
Posts: 117
Joined: 3-May 05
From: A Canadian South of the 49th Parallel
Member No.: 6,544



Try something like this:

CODE

<?php
 switch ($_GET['page']) {
 case "members":
  include 'members.php';
  break;
 case "diplomacy":
  include 'diplomacy.php';
  break;
 case "scrims":
  include 'scrims.php';
  break;
 case "forums":
  include 'forums.php';
  break;
 default:
  include 'home.php';
  break;
 }
?>


I hope that helps!
Go to the top of the page
 
+Quote Post
SystemWisdom
post Sep 13 2005, 02:46 AM
Post #6


Advanced Member
*******

Group: Members
Posts: 117
Joined: 3-May 05
From: A Canadian South of the 49th Parallel
Member No.: 6,544



Omg, sorry, I overlooked one more thing, the "include" part is actually a function, so it should have the () brackets.. Also, you should use the require() or require_once() functions when doing what you're doing, something like this:

CODE

require( 'members.php' );
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Guestbook (cgi-script) Problems(2)
  2. Trap17 Link Exchange Script Introduced(27)
  3. Need Help With Javascript Drag And Drop Script(2)
  4. Phpmyadmin Password Does Not Work(7)
  5. Java Script To Hide The Url In Address Bar(6)
  6. How Does Google Adsense Work?(9)
  7. Jsp Or Java Chat Script Like Mig33(5)
  8. Will Work Card On 4 Gb In Nokia N73 ?(2)
  9. Many Php Script Sites(16)
  10. Ndsl R4 Ds Revolution Chinese Hardware With English Firmware(3)
  11. Member Levels(26)
  12. Very Simple Online Now Script(4)
  13. Level Up System?(1)
  14. Remote Assistance Problem(9)
  15. [request] Avatar For Trap17 Users(0)
  1. Tutorial On How To Compile Your Own Mangos World Of Warcraft Private Server.(3)
  2. Build Your Own Business-100,000 Customers-no Bs(3)
  3. [help] Java Script: Window.open(10)
  4. Some Of My Photoshop Work(3)
  5. A Rant About Life And Work... Also A Plea For Advice(14)
  6. Help With Hosting - Cant Get Anything To Work [resolved](6)
  7. Razr Problems(19)
  8. Verifying Email Addresses(9)
  9. Delay X Seconds In Flash(1)
  10. Does Online Dating Work?(9)
  11. Web Surfing- Script Needed(2)
  12. Seeking Help With Javascript(1)
  13. Browser Compatibility Problem With Firefox - Javascript + Css(3)
  14. Wubi?(1)
  15. Job Vs Studies(13)


 



- Lo-Fi Version Time is now: 7th October 2008 - 01:46 AM