0

I am trying to fetch the flag field from mysql of the $_SESSION['sess_user'] But I dont know it never works with me... **

$c_user=$_SESSION['sess_user'];

    $queryflag = "SELECT `flag` FROM `members` WHERE `user`='" . $c_user . "'";
    $resultflag = mysql_query($queryflag);
    echo $resultflag;

**

0

2 Answers 2

1

You need to use mysql_fetch_array() or mysql_fetch_assoc()

$resultflag = mysql_query($queryflag) or die(mysql_error());
while ($row = mysql_fetch_assoc($resultflag)) {
  print_r($row)
}

Please note that mysql_* functions were deprecated, you need to switch to PDO or MySQLI

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

Comments

0

Try this method,

   $name = $_SESSION['sess_user'];
   $q = mysql_query("select flag from members where user='".$name."' ") or die(mysql_error());
   $res = mysql_fetch_assoc($q);
   $flag = $res['flag'];

You can use mysql_fetch_assoc() to retrieve filed from database here. Reference: here

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.