a problem withpassing information in the URL

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

Post Reply
ori
Forum Newbie
Posts: 4
Joined: Wed Apr 30, 2008 2:36 pm

a problem withpassing information in the URL

Post 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?
User avatar
lafever
Forum Commoner
Posts: 99
Joined: Sat Apr 05, 2008 2:03 pm
Location: Taylor, MI

Re: a problem withpassing information in the URL

Post 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>";
}
 
ori
Forum Newbie
Posts: 4
Joined: Wed Apr 30, 2008 2:36 pm

Re: a problem withpassing information in the URL

Post by ori »

I've corrected my code and surprisingly got exactly the same results.
?!
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: a problem withpassing information in the URL

Post by Zoxive »

Try using full php tags..

Code: Select all

<?php
/*
 
*/
?>
ori
Forum Newbie
Posts: 4
Joined: Wed Apr 30, 2008 2:36 pm

Re: a problem withpassing information in the URL

Post by ori »

Didn't help (and that's reasonable as I work with bluehost)
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Re: a problem withpassing information in the URL

Post 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?
ori
Forum Newbie
Posts: 4
Joined: Wed Apr 30, 2008 2:36 pm

Re: a problem withpassing information in the URL

Post 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.
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: a problem withpassing information in the URL

Post 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.
Post Reply