Page 1 of 1
a problem withpassing information in the URL
Posted: Wed Apr 30, 2008 2:44 pm
by ori
I've inserted the following code
<?
if (isset($_GET['a']) {
$id = (int) $_GET['a'];
print "<a href='
http://mydomain.net/?abc=$id'> here </a>";
}
else {
print "<a href='
http://mydomain.net/?abc=0'>here</a>";
}
?>
but the explorer ignores this while what I see in firefox is
here "; } else { print " here ";
and only the second "here" has a link (=0).
What is my mistake?
Re: a problem withpassing information in the URL
Posted: Wed Apr 30, 2008 2:49 pm
by lafever
You're missing a closing ) at the beginning of your if statement.
Code: Select all
if (isset($_GET['a'])) {
$id = (int) $_GET['a'];
echo "<a href='http://mydomain.net/?abc=$id'> here </a>";
} else {
echo "<a href='http://mydomain.net/?abc=0'>here</a>";
}
Re: a problem withpassing information in the URL
Posted: Wed Apr 30, 2008 3:03 pm
by ori
I've corrected my code and surprisingly got exactly the same results.
?!
Re: a problem withpassing information in the URL
Posted: Wed Apr 30, 2008 3:23 pm
by Zoxive
Try using full php tags..
Re: a problem withpassing information in the URL
Posted: Wed Apr 30, 2008 3:33 pm
by ori
Didn't help (and that's reasonable as I work with bluehost)
Re: a problem withpassing information in the URL
Posted: Thu May 01, 2008 2:17 am
by Mordred
Turn error_reporting() on.
View source to see exactly what the server gave you.
The code you pasted is not the code you use, maybe there's more to it? A quote is added, or missing?
Re: a problem withpassing information in the URL
Posted: Thu May 01, 2008 9:08 am
by ori
When I viewed the source I saw that the following appears in purple
<?
if (isset($_GET['a']) {
$id = (int) $_GET['a'];
print "<a href='
http://mydomain.net/?abc=$id'>
and the following was simply printed on the screen in my Firefox
here </a>";
}
else {
print "<a href='
http://mydomain.net/?abc=0'>here</a>";
}
?>
so I got in my browser
here "; } else { print here } ?>
this code ( I checked it again) appears in the middle of a text sentence in my html file.
Re: a problem withpassing information in the URL
Posted: Thu May 01, 2008 11:29 am
by Zoxive
#1 get in the habbit of using full tags. (Short tags is removed/disabled by default in future versions of php)
#2 are you positive you have php installed? (Its hard for us to tell be cause you could simply have short tags disabled.)
#3 you have a syntax error, you need another ) after the isset function to close the if statement.