6

Ok, here is my code. What it is supposed to do is retrieve the referer that sent you to the page, the user will type someurl.com/refcreate.php?ref=username

<?php
session_start();

$referer = $_GET['ref'];
$_SESSION['referer'] = $referer;

if (!isset($referer))
{
    echo 'You did not specify a referer, please correct this to continue';
    die;
}
elseif($referer == "")
{
    echo 'You did not specify a referer, please correct this to continue';
    die;
}

The above part works fine if they forgot to specify the referer. The below half is to check if the current referer specified is an actual user in the database.

if(refcheck($referer) = false)
    {
        echo 'that referer is not in our database,please double chek the spelling and try again.';
        die;
    }

    function refcheck($ref)
    {
        require('mysql_con.php');

        $query="SELECT username FROM jos_users WHERE username='". $ref ."'";
        echo $query;
        $result = mysql_query($query, $con);
        $exists =mysql_fetch_assoc($result);
        if ($exists != false)
        {
            //return true;      
            echo 'true';    
            return true;

        }

        require('mysql_close.php');
    }
    ?>

OK, I figured out the problem (or problems rather). 1 was it needed to look like this if(refcheck($referer) == false){} instead of if(refcheck($referer) = false);. So it was a missing equal sign and a misplaced colon :P thanks guys

3
  • 1
    Throwing in a pile of source code along with "it does not work, why is that?" isn't how this site works. Please post the relevant (!) bit of code here directly, explain what it is supposed to do, say what it actually does instead and ask a an actual question. Commented Mar 16, 2011 at 5:52
  • this question should be closed, as it will help noone Commented Mar 16, 2011 at 5:53
  • 1
    @ycs no this helped me - the question is a verbatim quote of the unhelpful php error message i was getting because of missing = Commented Aug 3, 2012 at 14:16

3 Answers 3

9

You're assigning a variable and not comparing it

This refcheck($referer) = false

Should be refcheck($referer) == false

Also, your method should have a default return if your IF condition fails.

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

Comments

0

ok i figured out hte problem or problems rather 1 was it need to look like this if(refcheck($referer) == false){} instead of if(refcheck($referer) = false); so a missing equal sign and a misplaced colon :P thanks guys

Comments

0

you misspelled "check" in the third line

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.