SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: Yeah, well... Query String you, too!

  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Los Angeles, CA
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Yeah, well... Query String you, too!

    I won't hesitate to say I'm very new to PHP, and getting into query strings is probably way over my level. I found a pretty good tutorial that introduced it very well, and using a bit of what I thought to be logic, I was hoping I could do something a bit more complicated. Apparently I messed up somewhere. It's not an error, but more that the test data I put in isn't displaying on the site and there's no sign of it in the source code. I'm pretty sure I know which file the issue is in, so I'll post that contents of that here. If it looks fine, I can share my other files as well.

    PHP Code:
    <?php
     
    include("content/prof/keit.php");
     include(
    "content/prof/naru.php");
     include(
    "content/prof/mits.php");

     if(
    $HTTP_GET_VARS['char'] == 'Keitaro')
      {
       
    $desc "$keit";
      }
     elseif(
    $HTTP_GET_VARS['char'] == 'Naru')
      {
       
    $desc "$naru";
      }
     elseif(
    $HTTP_GET_VARS['char'] == 'Kitsune')
      {
       
    $desc "$mits";
      }

     
    $PageTitle = ("Winter Wish - Character Profiles");
     require(
    "templates/header.php");
     require(
    "templates/navigation.php");
     
    $LocFile = ("profile.php");
     
    $LocTitle = ("Character Profiles");
     require(
    "templates/location.php");
     require(
    "content/prof/cont.php");
     require(
    "templates/footer.html");
    ?>
    The $desc variable is placed within cont.php.

  2. #2
    No. Phil.Roberts's Avatar
    Join Date
    May 2001
    Location
    Nottingham, UK
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is off-topic for Advanced PHP. Also you haven't clearly explained what your problem is.
    THE INSTRUCTIONS BELOW ARE OLD AND MAY BE INACCURATE.
    THIS INSTALL METHOD IS NOT RECOMMENDED, IT MAY RUN
    OVER YOUR DOG. <-- MediaWiki installation guide

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Los Angeles, CA
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Phil.Roberts
    This is off-topic for Advanced PHP. Also you haven't clearly explained what your problem is.
    I apologize. I wasn't sure exactly how difficult this issue was, just that I was completely baffled.

    As for my issue, I'll explain it as simply as I can:

    To test this all out, I input the following into keit.php:

    PHP Code:
    <?php
     $keit 
    "stuff lalalala";
    ?>
    Then I went to http://www.winter-wish.com/profile.php?char=Keitaro. If the code in my previous post is right, then it should display the aforementioned data (stuff lalalala) on the page. Instead, it displays nothing. No error, no text, nothing. All there is is a blank space in the source code where stuff lalalala should be.

    Is that better?

  4. #4
    SitePoint Enthusiast webchick's Avatar
    Join Date
    Jun 2004
    Location
    in front of a computer
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmm.. seems to be working fine here..?

    http://webchick.net/sp/profile.php?char=Keitaro (prints: stuff lalalala)

    I used the following abbreviated files to test:

    keit.php
    PHP Code:
    <?php
    $keit 
    "stuff lalalala";
    ?>
    profile.php
    PHP Code:
    <?php

    include('keit.php');


     if(
    $HTTP_GET_VARS['char'] == 'Keitaro')
      {
       
    $desc "$keit";
      }
    elseif(
    $HTTP_GET_VARS['char'] == 'Naru')
      {
       
    $desc "$naru";
      }
    elseif(
    $HTTP_GET_VARS['char'] == 'Kitsune')
      {
       
    $desc "$mits";
      } 

    echo 
    $desc;

    ?>
    Maybe check whatever file is displaying the results and make sure it's echoing $desc correctly?

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Los Angeles, CA
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's a good point. I figured that I could just use $desc in the display file, but that could definitely be wrong. How should it be echoed?

    EDIT: The file, in its simple glory:

    PHP Code:
    <?php
     $desc
    ?>

  6. #6
    SitePoint Enthusiast webchick's Avatar
    Join Date
    Jun 2004
    Location
    in front of a computer
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code to echo the $desc variable is just:

    PHP Code:
    <?php echo $desc?>
    This will print the contents of $desc to the screen.

    Btw, if the code you posted above actually *is* the entire file, you're missing a semi-colon which should've triggered a parse error..?

  7. #7
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Los Angeles, CA
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There we go, that works. Thanks a lot!

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
  •