1

Why is the construction brittle? I tried "!empty ( get_original_passhash() )" as a condition, but it ignites the error that you cannot use the return value.

if (  get_original_passhash () != '' ) 
{
    set_login_session ( get_original_passhash() );
}else
    print("Please, log in.");
3
  • 1
    uh? What are those functions they're not in standard php lib so unless we guess what they do or where do they come from we won't be able to help you. Commented Sep 4, 2009 at 15:49
  • p4bl0: please, see: pastebin.com/m6f6df104 Commented Sep 4, 2009 at 15:52
  • Please put the relevant code in your question rather than on a third party site. Commented Sep 4, 2009 at 21:51

2 Answers 2

2

I would be inclined to assign the variable before you test it, and probably also clean up your formatting a little too:

$original_hash = get_original_passhash();

if ($original_hash != ""){
    set_login_session(get_original_passhash());
} else {
    print("Please Log In");
}

You should also ensure that get_original_passhash() is returning the right type of variable - interger, string, boolean, etc.

Edit:

function get_original_passhash(){
    $dbconn = pg_connect("host=localhost port=5432 dbname=heoa user=heoa password=123");

    if(!empty($passhash_session)){
        return $passhash_session;
    } else {
        return $passhash_post;
    }
}

What is this code supposed to do? It connects to a database, and then tests a variable that just appears out of nowhere? Your code isn't working because, from the example's you've provided us, nothing is even being set. Is this the full source code for this function?

Sign up to request clarification or add additional context in comments.

1 Comment

+1 good point, the function get_original_passh was unnecessary.
1

You may want to split up your logic:

if (is_logged_in()) {
  set_login_session(get_original_passhash());
} else {
  print("Please Log In");
}

Since, in the conditional, you don't want the pass hash. You want to know if they're logged in or not.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.