Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    CPW
    CPW is offline
    Member
    Join Date
    Sep 2006
    Posts
    53
    Member #
    13935
    I've recently begun working on a new experimental site, but I'm running into problems. (yes, I've made other websites before, so I do have experience) So far all I'm doing is setting up variables. What I need to do is simply set a variable to a GET variable. If the variable is empty after doing that, it will assign it a default value. If stuff doesn't work I call an error function I made and some other stuff. But here's the problem. No matter what I name the variable, it won't take the value from $_GET['page']. It always ends up with just the first letter. I can directly echo the GET variable and it shows up fine. Also, if the GET variable is empty and the default value ("forum") is assigned, the code works beautifully. However, if I type "?page=forum" at the end of the address bar and reload the page with that on the end, my code doesn't work and the variable I assigned the GET value to only has the first letter ("f"). I can't figure out what's going on. I've tried numorous things, but I just can't get a variable to store the value I assign it from my GET variable. It seems really weird, so hopefully I am just missing something. Here's the problem section of my code:
    PHP Code:
    //Get page data
     
    $page_name $_GET['page']; //get page name
     
    if ($page_name == ""//if page name is not specified
     
    {
      
    $page_name "forum"//default value
     
    }
     
    $queryresult mysql_query("SELECT * FROM " $database['tableprefix'] . "community_pages WHERE name='" $page_name "'"); //query database
     
    if ($queryresult == true//if query executed properly
     
    {
      
    $result mysql_fetch_array($queryresult); //put record data in array
      
    if (mysql_num_rows($queryresult) > 0//if there is a record
      
    {   
       
    $page['id'] = $result['id']; //get page id
       
    $page['displayname'] = $result['displayname']; //get page display name
      
    }
      else 
    //otherwise give error
      
    {
       
    //error_redirect("pagenotfound", 1); //redirect to error
      
    }
     }
     else
     {
      
    //error_redirect("databaseerror", 1); //redirect to error
     

    This has gotten me frustrated because no matter what I do, it won't work. Maybe someone here can find my problem. Thanks for the help. :classic:

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    This *should* have no effect at all, but try changing your logic for the page name to this:
    PHP Code:
    $page_name = isset($_GET['page']) ? $_GET['page'] : 'forum'

  4. #3
    CPW
    CPW is offline
    Member
    Join Date
    Sep 2006
    Posts
    53
    Member #
    13935
    Thanks for the help, but I figured out the problem. Long story short, I'm actually using an array call $page[] for my page variables. I'm actually using $page['name'] instead of $page_name, but I have $page_name because I was changing things and testing them. It turns out that $page_name was getting the correct value, but my other values still stored in $page[] were not. I fixed the problem by setting $page[] to an empty array before using it, and now all works fine. Thanks for the help though.

  5. #4
    Senior Member raspberryh's Avatar
    Join Date
    Aug 2004
    Location
    Erie, PA
    Posts
    882
    Member #
    7208
    Liked
    1 times
    Man that's crazy - I'm glad you figured that out.
    choosy developers choose gif!
    website | paintings | blog

  6. #5
    CPW
    CPW is offline
    Member
    Join Date
    Sep 2006
    Posts
    53
    Member #
    13935
    Yeah, I'm not sure why I thought to try it. I was just messing around and decided to try it. Weird...


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:43 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com