Major Problem, seems to not make sense

Discussion in 'PHP' started by kc3, Dec 2, 2005.

  1. #1
    Here is some sample code-

    Returns this code for $quick_login

    When it should be returning this

    Did you notice the difference? It's the &id=asd and &id=index in the actions. But if I put print $link_code['2']; before or after where the $quick_login is declared that prints to correct code. To me this realy makes no sense at all. Oh, and the language file included does not do anything with any of the variables I'm describing so that's not what's causing it.

    Please help, I realy need to fix this.
     
    kc3, Dec 2, 2005 IP
  2. Dejavu

    Dejavu Peon

    Messages:
    916
    Likes Received:
    53
    Best Answers:
    0
    Trophy Points:
    0
    #2
    [Edit] no wait, that was wrong on my part.. let me check again..
     
    Dejavu, Dec 2, 2005 IP
  3. mika

    mika Active Member

    Messages:
    136
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #3
    I tried it on PHP 5.0.4 and it returns the right code... "&id=asd". Looks like you didn't post the whole code though...

    @Dejavu: Actually the "else" condition will only become active if $id == 'index' :)
     
    mika, Dec 2, 2005 IP
  4. kc3

    kc3 Peon

    Messages:
    857
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well there's about 40 pages of code but this is the only code involving this variable except for some mysql_querys that have the same problem.

    Even with these mysql querys they execute looking for an id of index, but if I put print $id in front or after that code it prints the right id.
     
    kc3, Dec 2, 2005 IP
  5. Dejavu

    Dejavu Peon

    Messages:
    916
    Likes Received:
    53
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yep, I saw that also.. its too late at night ha. Actually the 'else' condition does pretty much nothing here, not really needed.
     
    Dejavu, Dec 2, 2005 IP
  6. kc3

    kc3 Peon

    Messages:
    857
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yeah, it's declared in the url. I guess the fact that I added this code may affect some, I added it to my first post by the ways-
    The mainly wierd thing is that without calling and other files or variables, it will have the correct variable but the next line will have it wrong, than the next one will be right. Nothing is called or declared besides a print function.
     
    kc3, Dec 2, 2005 IP
  7. Dejavu

    Dejavu Peon

    Messages:
    916
    Likes Received:
    53
    Best Answers:
    0
    Trophy Points:
    0
    #7
    if ( $id **==** "" || empty( $id ) || $id == "index" ) {
    $id = "index";
    } else {
    }

    mm bold tags dont work here.. should be double equal signs
     
    Dejavu, Dec 2, 2005 IP
  8. kc3

    kc3 Peon

    Messages:
    857
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Whoops, yeah, in the original code that's what it is, it has the double = signs, I made the mistake when typing the message. My bad. lol

    Here's an extra code sample I made for an experiment.

    Here's what it does-

    Nothing is declared except for the $quick_login variable and the $id variable and $link_code variables are not changed.
     
    kc3, Dec 2, 2005 IP
  9. Dejavu

    Dejavu Peon

    Messages:
    916
    Likes Received:
    53
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Well that truly makes no sense. Try removing characters from the middle print statement, and see if you can isolate exactly when it starts to print the wrong stuff..
     
    Dejavu, Dec 2, 2005 IP
  10. kc3

    kc3 Peon

    Messages:
    857
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #10
    I tried removing everything but the $quick_login = $link_code['2'];
    Here's what my code looked like
    Than I tried renaming the variable to something no other files used.

    If you are not able to help me I thank you for taking a look at it and giving me your feedback. :) It is very much appreciated.

    If it does not work nomatter what I do, I'll redesign a lot of the software, may be a lot of work for 40 pages, but I can do it.
     
    kc3, Dec 2, 2005 IP