-3

How can I get 1 value from my database into my page in mysql(not mysqli)

code I have now is :

if (controle($username, $password) == true) {
    $resultaat = mysql_query("SELECT priviledged FROM klanten WHERE email='$user'");
    echo $resultaat;
    if($resultaat =2) {

        $_SESSION['user'] = $username;
        $_SESSION['pass'] = $password;
        $_SESSION['rights'] = 2;
        echo "U bent ingelogd! welkom klant";

        header("Refresh:1; URL=geheim.php");
    }
    else if ($resultaat = 1) {
        $_SESSION['user'] = $username;
        $_SESSION['pass'] = $password;
        $_SESSION['rights'] = 1;
        echo "U bent ingelogd! Welkom Ruud.";
        header("Refresh:1; URL=index.php");
    }
} if (controle($username, $password) == true) {
    $resultaat = mysql_query("SELECT priviledged FROM klanten WHERE email='$user'");
    echo $resultaat;
    if($resultaat =2) {

        $_SESSION['user'] = $username;
        $_SESSION['pass'] = $password;
        $_SESSION['rights'] = 2;
        echo "U bent ingelogd! welkom klant";

        header("Refresh:1; URL=geheim.php");
    }
    else if ($resultaat = 1) {
        $_SESSION['user'] = $username;
        $_SESSION['pass'] = $password;
        $_SESSION['rights'] = 1;
        echo "U bent ingelogd! Welkom Ruud.";
        header("Refresh:1; URL=index.php");
    }
}`

I get an echo result of $resultaat as recource id #8 but I need $resultaat to give me an echo that gives back the value of 'priviledged' so a 1 or 2, depending on what is says in the database.

Bellerofont
  • 1,081
  • 18
  • 17
  • 16
Apoxxis
  • 1
  • 1

1 Answers1

0
$resultaat = mysql_query("SELECT priviledged FROM klanten WHERE email='$username'");
While($data = mysql_fetch_array($resultaat))
{
   echo $data['priviledged'];
}
Gransfall
  • 147
  • 6
  • you missed quite a few things – Funk Forty Niner Jan 13 '17 at 12:42
  • Plus, that isn't what the question is about. Go over their code and the question again; you will see it contains many errors. – Funk Forty Niner Jan 13 '17 at 12:46
  • I quote : "I need $resultaat to give me an echo that gives back the value of 'priviledged' so a 1 or 2" He want the priviledged value in is database for check the access , i don't see the problem – Gransfall Jan 13 '17 at 12:55
  • again; look at the code they're using and see what is "not" happening here. My comments under it will give you a better idea. – Funk Forty Niner Jan 13 '17 at 12:58
  • you talk about $username in controle function and after $user in request, after the header will not work etc etc... ? also i miss the point in request ^^ *crap* – Gransfall Jan 13 '17 at 13:24
  • no, read my comments under the question again; all of them. This includes the possible duplicate. I'm not trying to insult you here, but if your php skills were high enough, you would have immediately spotted the assignments rather than comparisons, including their outputting before header. – Funk Forty Niner Jan 13 '17 at 13:26
  • and the edit you just made `email='.$username.'` is incorrect. I highly doubt that that is an integer but a string. There was nothing wrong with `email='$user'`. – Funk Forty Niner Jan 13 '17 at 13:28
  • I feel that you may have answered a question that will use up a lot of your time and energy. Their code contains a lot of errors and there are some unknown functions that we don't know what they do. You may be wasting your time; take this from experience. – Funk Forty Niner Jan 13 '17 at 13:32