SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    here I have an if statement... well .. I guess u could figure that out with me telling u.. anyways.. the first statement will be true.. but then everything inside it happens.. lets say i have a link
    <a href = "fafdsafdsas.php?actionvar=name">fds</a>

    see now.. it should only do the one nested if statement.. however for some sick disgusting reasson.. its doing both?

    if (isset($actionvar))
    {
    if ($actionvar = "name")
    {
    whatever....
    }

    if ($actionvar ="username")
    {
    whatever....
    }
    }

  2. #2
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Try:

    if (isset($actionvar)) {
    if ($actionvar = "name") {
    whatever....
    } elseif ($actionvar ="username") {
    whatever....
    }
    }

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    Washington State
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is a classic case of = vs. == vs. === vs != vs ... for example :

    if ($actionvar = "name") {

    should be :

    if ($actionvar == "name")

    Otherwise $actionvar will ALWAYS equal to "name" which is not what you're wanting. Read up on comparison operators :

    http://php.net/manual/en/language.op...comparison.php


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
  •