Results 1 to 6 of 6
  1. #1
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default Why wont this code work :S

    Well im trying to get this code to check if the user is allready there friend, and if not displays a Ask to be friend button.
    It needs to check:
    If theres allready a "logged username and profile username" and a "profile username and a logged username" (So theres two places it could be).
    The current code is below.
    PHP Code:
    <?
    include("config.php");
    if(
    $logged[username] && $logged[rank] == member OR admin OR mod){
    $getfriend mysql_query("SELECT * FROM friends");
    $fr mysql_fetch_array($getfriend);
    if(
    "$fr[to_user] = '$profile[username]' WHERE $fr[from_user] = '$logged[username]'"){
    echo(
    "<br><font size=\"1\">$profile[username] is already your friend!</font>");
    } elseif (
    "$fr[to_user] = '$logged[username]' WHERE $fr[from_user] = '$profile[username]'"){
    echo(
    "<br><font size=\"1\">$profile[username] is already your friend!</font>");
    } else {
    echo(
    "User isn't friend);
    }
    }
    ?>
    I keep getting "User is already your friend" even when there not

  2. #2
    Join Date
    Dec 2006
    Location
    Swindon
    Posts
    3,299
    Tokens
    215
    Habbo
    dunko

    Latest Awards:

    Default

    Your coding is crap.

    PHP Code:
    <?php
    include("config.php");

    if( 
    $logged["username"] )
    {
        if( 
    $logged["rank"] == "member" || $logged["rank"] == "admin" || $logged["rank"] == "mod" )
        {
            
    $sql mysql_query("SELECT * FROM friends");
            
    $result mysql_fetch_array($sql);
            if( 
    $result["to_user"] == $profile["username"] && $result["from_user"] == $logged["username"] )
            {
                echo 
    '<br /><font size="1">' $profile["username"] . ' is already your friend!</font>';
            } 
            elseif( 
    $result["to_user"] == $logged["username"] && $result["from_user"] == $profile["username"] )
            {
                echo 
    '<br /><font size="1">' $profile["username"] . ' is already your friend!</font>';
            } 
            else
            {
                echo 
    'This user isn\'t your friend.';
            }
        }
    }
    ?>

  3. #3
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    Thanks, but theres 1 problem, once it gets the results from the first if, it dosn't do the other elseif's so is there a way do to it all on one if?

  4. #4
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    Ew, dont use the techtuts usersystem :S
    Coming and going...
    Highers are getting the better of me

  5. #5
    Join Date
    Jan 2007
    Posts
    651
    Tokens
    0

    Default

    Do you even have a ask to be friend button in that code ?
    James


    Connected to reality through a proxy server.

  6. #6
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    Quote Originally Posted by Mr Macro View Post
    Do you even have a ask to be friend button in that code ?
    Well im using a image button and it has the URL to the files so I removed it when I posted the code

Posting Permissions

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