SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    get variable not echoing

    if folks, i m creating a page for some expermintal purpose and i m trying to echo value of url clicked but it isn't echoing. i tried the mysql_error() in if statement but that too doesn't show up. what am i missing?
    Code PHP:
    if(isset($_GET['page'])){
        $sel_page = $_GET['page'];
            if(!isset($_GET['page'])){
                echo mysql_error();
            }
    }else{
        $sel_page = $_GET['page'] = "";    
    }
    here is the link
    Code PHP:
    echo "<a href=\"content.php?page =" . urlencode($row["id"]). "\"><li>{$row["menu_name"]}</a></li>"
    and here is the get echo
    Code PHP:
    echo "$sel_page";
    All those who wander aren't lost.

  2. #2
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    336
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I am not seeing the whole code so I don't why/where mysql_error() would come into play. Anyway I think you want this:

    PHP Code:
    if( isset($_GET['page']) ) {
        echo 
    $_GET['page'];
    } else {
        echo 
    'Page not set';


  3. #3
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    now it says page not found, here is the full page code
    Code PHP:
    <?php require("includes/functions.php"); ?>
    <?php
    if(isset($_GET['page'])){
        echo $_GET['page'];
    }else{
        echo "Page not found";
    }
    ?>
    <body>
     
    <div class="container">
      <div class="sidebar1">
      <?php 
      $con = mysql_connect("localhost","root","");
      confirm($con);
      $seldb = mysql_select_db("sandbox");
     confirm($seldb);
     //$query = "select * from subjects";
    //$subject_set = mysql_query($query);
     $parent = get_subjects($subject);
    ?>
    <ul>
     
    <?php 
     while($subjects=mysql_fetch_array($parent))
     {
             echo "<a href=\"\"><li>{$subjects["menu_name"]}</a></li>";
     
                $pageResult = get_pages($subjects["id"]);
                echo "<ul class=\"nested\">";
                while($row = mysql_fetch_array($pageResult)){
                    echo "<a href=\"content.php?page =" . urlencode($row["id"]). "\"><li>{$row["menu_name"]}</a></li>";
                }
                echo "</ul>";
     }
      ?>
    </ul>  
        </div>
      <div class="content">
      <h1>Here</h1>
        <?php
            echo ($sel_page);
            ?>
        <!-- end .content --></div>
      <!-- end .container --></div>
    what am i missing?
    All those who wander aren't lost.

  4. #4
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I figured out the reason i had space between page and =. But to my knowledge white spaces aren't significant. then the error?
    All those who wander aren't lost.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •