PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Tom
Forum Newbie
Posts: 20 Joined: Sat Oct 05, 2002 5:24 pm
Location: Southwest FL
Post
by Tom » Sat Oct 05, 2002 5:24 pm
Alright.
I'm trying to make my index.php page to where I can make links look like "index.php?goto=links".
In the index.php file I have this:
Code: Select all
<?php
switch ($goto) {
case "downloads":
include('downloads.php');
break;
default:
include('main.php');
break;}
?>
Now here's where my problem is. I've checked my code at least 10 times and I can't seem to figure out why I keep getting this:
"Warning: Undefined variable: goto in c:\my documents\site\flballer\new\index.php on line 2"
When i used to have a small website and I played around with php, I never got anything like this while doing the "index.php?page=blah" code.
Pleaaaasee Help!
Take it Easy, - Tom.
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Sat Oct 05, 2002 5:36 pm
try this:
Code: Select all
<?php
switch ($_GETї'goto']) {
case "downloads":
include('downloads.php');
break;
default:
include('main.php');
}
?>
1) read this
viewtopic.php?t=511
2) you don't need to put a break; in the default: switch
Tom
Forum Newbie
Posts: 20 Joined: Sat Oct 05, 2002 5:24 pm
Location: Southwest FL
Post
by Tom » Sat Oct 05, 2002 6:01 pm
Thanks, but it doesn't work. It's still trying to tell me this:
"Warning: Undefined variable: _GET in c:\my documents\site\index.php on line 2"
Take it easy, - Tom.
Takuma
Forum Regular
Posts: 931 Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:
Post
by Takuma » Sun Oct 06, 2002 3:02 am
That's probably you got a old version of PHP try using $HTTP_GET_VARS instead of $_GET
Did you try this?
Last edited by
Takuma on Sun Oct 06, 2002 1:37 pm, edited 1 time in total.
Tom
Forum Newbie
Posts: 20 Joined: Sat Oct 05, 2002 5:24 pm
Location: Southwest FL
Post
by Tom » Sun Oct 06, 2002 9:13 am
I erased everything that had to do with php on my computer (besides php files i had written, of course) and made sure i followed the directions correctly. I still don't know what was wrong, but it seems to work fine now
. Thanks guys!
Take it easy, - Tom.
Takuma
Forum Regular
Posts: 931 Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:
Post
by Takuma » Sun Oct 06, 2002 10:52 am
Was it anything to do with register_globals? That seems to be causing a lot of troubles.
Tom
Forum Newbie
Posts: 20 Joined: Sat Oct 05, 2002 5:24 pm
Location: Southwest FL
Post
by Tom » Sun Oct 06, 2002 1:19 pm
It's got nothing to do with Register_Globals. I'm using 4.0.6 because I have 56k and never decided to wait the 40 minutes or so to download the newest versions every 3 weeks or so..
Take it easy, - Tom
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Sun Oct 06, 2002 2:14 pm
Hopefully you'll find the lastest version worth the wait. You shouldn't need to upgrade again until they finally release 4.3.
Mac
Oxy
Forum Newbie
Posts: 17 Joined: Fri Apr 19, 2002 5:47 am
Location: U.K
Contact:
Post
by Oxy » Tue Oct 08, 2002 9:46 am
Your using PHP with higher than normal error reporting settings, which means you need to define each variable before you use it or turn down your error setting.
Put this at the top of your script
or this to turn off error reporting
Wayne
Forum Contributor
Posts: 339 Joined: Wed Jun 05, 2002 10:59 am
Post
by Wayne » Wed Oct 09, 2002 3:56 am
you shouldnt need to do either of those suggestions, you should have your own error handling that will trap the event and prevent the error from being displayed. If you set the variable at the top of the page you are just going to overwrite any variable passed to the script if GLOBALS are turned on, and just cause problems later on when trying to determine the value of $goto.
Pocketx
Forum Commoner
Posts: 37 Joined: Fri Aug 23, 2002 9:54 pm
Post
by Pocketx » Sat Nov 23, 2002 10:59 pm
Hmm.. when i try
<?php
switch ($_GET['page']) {
case "downloads":
include('downloads.php');
break;
case "downloads&download_id=1":
include('games/1.php');
break;
default:
include('main.php');
}
?>
When i try with the & on the browser, it doesnt work, it only gose to the page downloads.. Help please!!
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Sat Nov 23, 2002 11:03 pm
try something like this:
Code: Select all
if(isset($_GETї'downloads']){
if(!isset($_GETї'download_id']){
include 'downloads.php';
} else if($_GETї'download_id'] == "1"){
include 'games/1.php';
}
}
Pocketx
Forum Commoner
Posts: 37 Joined: Fri Aug 23, 2002 9:54 pm
Post
by Pocketx » Sat Nov 23, 2002 11:10 pm
Thanks! But if i were to imigrate it into the original code, how will it look like? Because i got some errors
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Sat Nov 23, 2002 11:40 pm
Code: Select all
if($_GETї'page'] == "downloads"){
if(!isset($_GETї'download_id']){
include 'downloads.php';
} else if($_GETї'download_id'] == "1"){
include 'games/1.php';
}
} else {
include('main.php');
}
does that work? what are the errors?
Pocketx
Forum Commoner
Posts: 37 Joined: Fri Aug 23, 2002 9:54 pm
Post
by Pocketx » Sat Nov 23, 2002 11:43 pm
Code: Select all
Parse error: parse error in /mnt/host-users/pocketx/test/index.php on line 7
My code:
Code: Select all
<?php
switch ($_GETї'page']) {
case "downloads":
include('downloads.php');
break;
if($_GETї'page'] == "downloads"){
if(!isset($_GETї'download_id']){
include 'downloads.php';
} else if($_GETї'download_id'] == "1"){
include 'games/1.php';
}
} else {
include('main.php');
}
?>
I also did this
Code: Select all
<?php
if($_GETї'page'] == "downloads"){
if(!isset($_GETї'download_id']){
include 'downloads.php';
} else if($_GETї'download_id'] == "1"){
include 'games/1.php';
}
} else {
include('main.php');
}
?>
And I get this
Code: Select all
Parse error: parse error in /mnt/host-users/pocketx/test/index.php on line 3