Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default function not evaluating correctly

    Heres my function, it always returns 0...

    PHP Code:
    function user_type($page) {
        
    $user $logged_user;
        
    $level mysql_query("SELECT * FROM users WHERE user='$user'");
        
    $level_a mysql_fetch_array($level);
        
    $final_level $level_a['usergroup'];
        
    $check_level mysql_query("SELECT * FROM userstructure WHERE name='$final_level'");
        
    $check_level_a mysql_fetch_array($check_level);
        if ( 
    $check_level_a[''.$page.''] == '1' ) {
            return 
    "1";
        } else {
            return 
    "0";
        }

    Heres how I use it in a backend page: ex. testimonials:



    PHP Code:
    if(user_type("testimonials") == "0") {
        
    header("Location: notallowed.php");
        exit();

    Moved by Hitman (Forum Moderator) from Designing & Development: Please post in the correct forum next time, thanks.
    Last edited by Hitman; 27-03-2008 at 05:07 PM.
    How could this hapen to meeeeeeeeeeeeeee?lol.

  2. #2
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    God, learn how to code. What the heck is this?
    PHP Code:
    $check_level_a[''.$page.''] == '1' 
    Your going to need to use a global I believe,

    However, within user-defined functions a local function scope is introduced. Any variable used inside a function is by default limited to the local function scope.
    PHP Code:
    <?php
    function user_type ($page)
    {
        global 
    $logged_user;
        
    $level mysql_query("SELECT * FROM users WHERE user='$user'"); // QUIT USING WILDCARDS =\
        
    $level_a mysql_fetch_array($level); // You took my structure :@
        
    $final_level $level_a["usergroup"];
        
    $check_level mysql_query("SELECT * FROM userstructure WHERE name='$final_level'");
        
    $check_level_a mysql_fetch_array($check_level);
        if (
    $check_level_a[$page] == "1") {
            return 
    "1";
        } else {
            return 
    "0";
        }
    }

    $user_type user_type("testimonials");
    if(
    $user_type == "0") {
        
    header("Location: notallowed.php"); // This is stupid, it relies on the browser to redirect, plus it ***** up with sessions.
        
    exit();
    }
    ?>

  3. #3
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    I realised the syntax in ''$var''

    the global worked. thanks =)
    How could this hapen to meeeeeeeeeeeeeee?lol.

  4. #4
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Ummm.. what?

  5. #5
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    $level = mysql_query("SELECT * FROM users WHERE user='$user'"); // QUIT USING WILDCARDS =\
    wildcards are fine unless you're pulling out a stupid amount of data which I highly doubt.


    $level_a = mysql_fetch_array($level); // You took my structure :@
    what structure

    header("Location: notallowed.php"); // This is stupid, it relies on the browser to redirect, plus it ***** up with sessions.
    All redirects rely on the browser. And it doesn't mess up with sessions.


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  6. #6
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    If the stupid sessions goes bazackwhap, it throws out a nice little error about sending **** before the sessions headers already sent all that meatwhack.

    I showed him my source code to something, and now his _a, _n, looks like mine.

  7. #7
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    Meh, I'll throw out an error, it exit();'s anyway tbh.
    How could this hapen to meeeeeeeeeeeeeee?lol.

  8. #8
    Join Date
    Feb 2008
    Location
    Plymouth
    Posts
    1,073
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Housekeeping View Post
    If the stupid sessions goes bazackwhap, it throws out a nice little error about sending **** before the sessions headers already sent all that meatwhack.

    I showed him my source code to something, and now his _a, _n, looks like mine.
    Some people never change I guess:rolleyes:

  9. #9
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    lol, it's better than what I used to have:

    $query
    $result
    $row
    $querya
    $resulta
    $row
    $queryasox
    $resultex
    $rowarc

    I changed the language almost.
    How could this hapen to meeeeeeeeeeeeeee?lol.

  10. #10
    Join Date
    Feb 2008
    Location
    Plymouth
    Posts
    1,073
    Tokens
    0

    Latest Awards:

    Default

    Lmao why did you use $rowarc o.0

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •