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
Achilles_Force
Forum Newbie
Posts: 9 Joined: Wed Feb 06, 2008 7:17 pm
Post
by Achilles_Force » Wed Feb 06, 2008 8:30 pm
Cant get the following to work
Code: Select all
<h1>Page title</h1>
<p>Select:
<a href="index.php?y=subpages">back</a> |
<a href="index.php?y=subpages&x=1">link 1</a> |
<a href="index.php?y=subpages&x=2">link 2</a> |
<a href="index.php?y=subpages&x=3">link 3</a> |
</p>
<? if(!$x) { ?>
000000<!-- main content should appear here :\ -->
<? } elseif ($x == "1") { ?>
111111<!-- Content for x1 SHOULD be here -->
<? } elseif ($x == "2") { ?>
222222<!-- Content for x2 SHOULD be here -->
<? } elseif ($x == "3") { ?>
33333<!-- Content for x3 SHOULD be here -->
<? } ?>
PLEASE some help. THANKS!
Last edited by
Achilles_Force on Thu Feb 07, 2008 6:50 pm, edited 1 time in total.
Festy
Forum Commoner
Posts: 28 Joined: Wed Jan 30, 2008 10:01 pm
Post
by Festy » Wed Feb 06, 2008 11:11 pm
What error are you getting exactly?
Achilles_Force
Forum Newbie
Posts: 9 Joined: Wed Feb 06, 2008 7:17 pm
Post
by Achilles_Force » Thu Feb 07, 2008 4:21 pm
not an "error". it just wont work.. :\ (I run php5)
VladSun
DevNet Master
Posts: 4313 Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria
Post
by VladSun » Thu Feb 07, 2008 4:26 pm
Place this at the very beginning of your code:
This is because register_globals is set to Off in your php.ini... and it should be!
Last edited by
VladSun on Thu Feb 07, 2008 6:20 pm, edited 2 times in total.
There are 10 types of people in this world, those who understand binary and those who don't
Achilles_Force
Forum Newbie
Posts: 9 Joined: Wed Feb 06, 2008 7:17 pm
Post
by Achilles_Force » Thu Feb 07, 2008 6:14 pm
Code: Select all
<h1>Page title</h1>
<p>Select:
<a href="index.php?y=subpages">back</a> |
<a href="index.php?y=subpages&x=1">link 1</a> |
<a href="index.php?y=subpages&x=2">link 2</a> |
<a href="index.php?y=subpages&x=3">link 3</a> |
</p>
<? if(!$x) { ?>
$x = intval($_GET['x']);
000000<!-- main content should appear here :\ -->
<? } elseif ($x == "1") { ?>
111111<!-- Content for x1 SHOULD be here -->
<? } elseif ($x == "2") { ?>
222222<!-- Content for x2 SHOULD be here -->
<? } elseif ($x == "3") { ?>
33333<!-- Content for x3 SHOULD be here -->
<? } ?>
Like that? :S
VladSun
DevNet Master
Posts: 4313 Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria
Post
by VladSun » Thu Feb 07, 2008 6:20 pm
VladSun wrote: Place this at the very beginning of your code:
There are 10 types of people in this world, those who understand binary and those who don't
Achilles_Force
Forum Newbie
Posts: 9 Joined: Wed Feb 06, 2008 7:17 pm
Post
by Achilles_Force » Thu Feb 07, 2008 6:23 pm
Code: Select all
<h1>Page title</h1>
<p>Select:
<a href="index.php?y=subpages">back</a> |
<a href="index.php?y=subpages&x=1">link 1</a> |
<a href="index.php?y=subpages&x=2">link 2</a> |
<a href="index.php?y=subpages&x=3">link 3</a> |
</p>
<? $x = intval($_GET['x']); if(!$x) { ?>
000000<!-- main content should appear here :\ -->
<? } elseif ($x == "1") { ?>
111111<!-- Content for x1 SHOULD be here -->
<? } elseif ($x == "2") { ?>
222222<!-- Content for x2 SHOULD be here -->
<? } elseif ($x == "3") { ?>
33333<!-- Content for x3 SHOULD be here -->
<? } ?>
uhh.. Cant you just post an example? ^_^"
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Thu Feb 07, 2008 6:30 pm
The general concept is that you don't want to check $x (i.e., if (!$x) ) before you have assigned a value to $x.
Code: Select all
<?php
$x = intval($_GET['x']);
if(!$x) {
(#10850)