passign URL variables

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
bdee1
Forum Newbie
Posts: 10
Joined: Wed Jan 14, 2009 12:18 pm

passign URL variables

Post by bdee1 »

i am having some trouble buildign links that have url variables.

i am trying to build a link that looks like this:

Code: Select all

<a href="deleteItem.php?id=7">X</a>
i am using the following code:

Code: Select all

 
echo("<a href='deleteItem.php?id=".$id."'>X</a>")
 
but the browser renders the link as:

Code: Select all

 
<a href='deleteItem~id~4.php'>X</a>
 
what am i doing wrong??
User avatar
it2051229
Forum Contributor
Posts: 312
Joined: Tue Dec 25, 2007 8:34 pm

Re: passign URL variables

Post by it2051229 »

I did a test but it rendered it correctly. Give more codes
bdee1
Forum Newbie
Posts: 10
Joined: Wed Jan 14, 2009 12:18 pm

Re: passign URL variables

Post by bdee1 »

it2051229 wrote:I did a test but it rendered it correctly. Give more codes
Is there some kind of php.ini setting that would cause this ?
What other code can I supply?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: passign URL variables

Post by califdon »

You're saying that the browser address bar shows precisely: <a href='deleteItem~id~4.php'>X</a> ? My first guess is that it's a browser issue. Try viewing with another browser. You're saying that the .php? doesn't even come through?! I've never heard of something like that happening.
bdee1
Forum Newbie
Posts: 10
Joined: Wed Jan 14, 2009 12:18 pm

Re: passign URL variables

Post by bdee1 »

yes thats exactly what is happening... i have tried it in ie7, ie8 and firefox. same result.


test for yourself at http://www.blairdee.info/php

the links i am referring to are the X links next to each item.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: passign URL variables

Post by califdon »

Well, you're right, that's what's in the source code. So in order to offer you any help, you'll need to supply the surrounding PHP code that is creating the links. More than just the one line. Obviously, the variable that you THINK contains just the ID must contain some other characters; the issue is where it's coming from.
bdee1
Forum Newbie
Posts: 10
Joined: Wed Jan 14, 2009 12:18 pm

Re: passign URL variables

Post by bdee1 »

califdon wrote:Well, you're right, that's what's in the source code. So in order to offer you any help, you'll need to supply the surrounding PHP code that is creating the links. More than just the one line. Obviously, the variable that you THINK contains just the ID must contain some other characters; the issue is where it's coming from.
ok gotcha... well heres the complete source code...

Code: Select all

 
<?php
#PARSING THE XML FILE USING SIMPLEXML... for mor info google "SimpleXML"
 
#CREATING THE HANDLER
#
$xml = simplexml_load_file('file.xml');
 
#
#LOOP THROUGH  THE <LINKGROUP> NODES
#
foreach($xml->linkGroup as $linkGroup)
{
    $linkGroupTitle = $linkGroup['id']; 
    echo("<strong>Link Group: " . $linkGroupTitle . "</strong><br/>");
    
    #
    #REMOVE THE FIRST <linkItem> NODE
    #
    #unset($linkGroup->linkItem[0]);
    
        
    echo("<ul>");
    
    #
    #LOOP THROUGH  THE <LINKITEM> NODES (CHILD OF <LINKGROUP>
    #
    foreach($linkGroup->linkItem as $linkItem)
    {
        $id = $linkItem['id'];
        $title = $linkItem->title;
        $url = $linkItem->url;
        $description = $linkItem->description;
        ?>
            <li>
                (ID <?php echo($id)?>)<?php echo($title)?><br>
                <?php echo($description)?><br>
                <a href="<?php echo($url)?>"><?php echo($url)?></a>
                 [<a href="deleteItem.php?id=<?php echo($id)?>">X</a>]<br><br>
            </li>
        <?php
        
        #echo("<li>".$id.": ".$title.": ".$url." [<a href='deleteItem.php?id=".$id."'>X</a>]</li>");
    }
    echo("</ul>");
}
 
?>
<br>
<a href="addItem.php">Add another link</a>
 
 
and here is the xml file:

Code: Select all

 
<?xml version="1.0" encoding="utf-8"?>
<linkCollection>
    <linkGroup id="Photoshop">
        <linkItem id="1">
            <title>Google</title>
            <description>This is the first link</description>
            <url>www.google.com</url>
        </linkItem>
        <linkItem id="2">
            <title>blairdee.info</title>
            <description>This is the second link</description>
            <url>www.blairdee.info</url>
        </linkItem>
        <linkItem id="3">
            <title>Microsoft Windows 7 Website</title>
            <description>This is the third link</description>
            <url>www.microsoft.com/windows7</url>
        </linkItem>
        <linkItem id="4">
            <title>Fandango</title>
            <description>This is the fourth Link</description>
            <url>www.fandango.com</url>
        </linkItem>
    </linkGroup>
</linkCollection>
 
 
bdee1
Forum Newbie
Posts: 10
Joined: Wed Jan 14, 2009 12:18 pm

Re: passign URL variables

Post by bdee1 »

ok so heres something interestign, i emailed the two files to a buddy who is running wamp on his local machine and he ran them and it worked just fine. so it HAS to be some kind of setting with my php install... what could it be??
bdee1
Forum Newbie
Posts: 10
Joined: Wed Jan 14, 2009 12:18 pm

Re: passign URL variables

Post by bdee1 »

ok problem solved... turns out i had an old IIS plugin called LinkFreeze which was some kind of url renaming tool. i uninstalled it and its fixed.
Post Reply