$_GET variable problem

I am trying to pass a variable from page 1 to page 2 using an call so I can use the variable on page 2 with $_GET. However, I never get to page 2 because what I think is my variable is being appended to the file name.

<?php $url = '\.\./catpg.php?catid='.($row_categories['CategoryID']); ?>
      '<li><a href="<?php echo ($url); ?>" name="AllSubs"> See All <?php echo($row_categories['CategoryName']); ?></a></li>

When the link is clicked, the browser looks for catpg.php?catid=1. This tells me I m getting the correct id from my query, but I can’t get the page “catpg.php” to load, so I can use the variable. I have fussed with this for 2 days. Any help would be most appreciated. (No live website, just testing at this point, and the directory http://localhost/catpg.php is correct.)

I’d format the link in a cleaner way such as:

  • See All <?php echo $row_categories['CategoryName'];?>
  • are you certain the array items are not empty as reading your code I don’t see anything wrong with it.

    Actually, your suggestion is my original code. I have been playing with it in various ways attempting to get it to work. The arrays are not empty (I have triple checked that fact.) If I remove my variable and insert a constant (such as catid=3) my browser still attempts to load “catph.php?catid=3”, so I don’t think the problem is with the array. Do I need to declare an empty $_GET variable before this code is executed? I have session_start(); at the beginning of the file, but I have not declared the $_GET variable there. Since I can’t seem to get to the next page, I can’t determine if the variable is available. Thanks for your prompt reply.

    oh I see what your saying now, you don’t need to declare $_GET as it’s a global variable.

    when passing variables to pages your doing it right but it appears your using the same page and passing the catid to determine the content to load. so catph.php?catid=1 is the same as catph.php?catid=3 the only difference is the id being passed so that should determine the content being loaded.

    So ff I understand you correctly your using the same page for the content, how I would do it is load the content determined from the get id nothing has been passed then load some default content

    [php]<?php
    //include database settings ect

    if(isset($_GET[‘catid’])){ //get requested id from url

    $catid = $_GET[‘catid’];
    $catid = mysql_real_escape_string($catid);

    //query database and pull content for selected catid
    

    } else { // nothing has being passed via get load some default content
    echo “hello”;
    }
    ?>[/php]

    Okay, now I feel really dumb… Things work in Safari & Firefox like they should. Seems that IE8 is my problem child here. Even though I feel dumb for not checking that, at least I now know I am not crazy when it appeared that everything was right with my code! If you have any suggestions for IE 8 I’m open to them, otherwise I’ll be taking that trail next.

    Thanks for prompt replies and attempts to help. I think this site/forum is great help. Sometimes it just takes a little push or a comment from someone to get me back on track, and since I work alone, I don’t get much of that.

    Till next time…Thanks again!

    that is very strange the only time things would play up in an IE browser most of the time comes down to commenting or rather text pasted from application like Microsoft Word as sometimes hidden code gets copied and IE does not understand it and can break the page, other browsers are smart enough to ignore the comments.

    Other then that I have no idea without seeing your script.

    Your very welcome, I love forums there a great way to learn I’ve learnt all sorts over the years from them so if I can help others then great.

    Sponsor our Newsletter | Privacy Policy | Terms of Service