SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem w/ equal values

    hi!
    i dont know how to put the value from sql query to equal and not!
    example:

    PHP Code:
    if($_SESSION["class"] == 'admin') {
    goHere();

    now the function go(); run if the session class is admin!
    but how to put if session class is not equal to admin?
    example:
    PHP Code:
    if($_SESSION["class"is not 'admin') {
    goThere();

    any help appreciated!
    thanx in advance

  2. #2
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if($_SESSION["class"] == 'admin') {
      
    goHere();
    } else {
      
    goThere();

    or
    PHP Code:
    if($_SESSION["class"] != 'admin') {
      
    goThere();

    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  3. #3
    SitePoint Zealot IznSe7en's Avatar
    Join Date
    Jun 2004
    Location
    Around
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sweatje
    PHP Code:
    if($_SESSION["class"] == 'admin') {
      
    goHere();
    } else {
      
    goThere();

    or
    PHP Code:
    if($_SESSION["class"] != 'admin') {
      
    goThere();

    It needs to be "!==", proper syntax.
    ><

  4. #4
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by IznSe7en
    It needs to be "!==", proper syntax.
    If what you are trying to say is that $_SESSION["class"] is not 'admin' and both $_SESSION["class"] and 'admin' are strings, however, $_SESSION["class"] and 'admin' will never be equal without both of them being strings, so the type comparison is irelevant in this case.

  5. #5
    SitePoint Zealot IznSe7en's Avatar
    Join Date
    Jun 2004
    Location
    Around
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sweatje
    If what you are trying to say is that $_SESSION["class"] is not 'admin' and both $_SESSION["class"] and 'admin' are strings, however, $_SESSION["class"] and 'admin' will never be equal without both of them being strings, so the type comparison is irelevant in this case.
    Good point. Touche.
    ><

  6. #6
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanx guys!
    cheers

  7. #7
    <? james('rules'); ?>
    Join Date
    Jun 2004
    Location
    Wales, UK
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if($_SESSION['class'] == 'admin'){

    goHere();

    } else {

    goThere();


    Or:
    PHP Code:
    if($_SESSION['class'] !== 'admin') {

    goThere();


    Or:
    PHP Code:
    if(!$_SESSION['class'] == 'admin') {

    goThere();
     
    } else {

    goHere();
     

    Many Many different ways .

    Regards,


    1337
    If knowledge is power - Why isn't our army librarians?!
    Statistics show that 63% of all statistics are fake.
    When i was little i broke my neck, and i havent looked back since .
    I completed the internet in 1 week. The end boss was pretty easy though .


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
  •