0

i need to update ADMIN COLUMN with $_SESSION variable. however, it does not seem to be working correctly. why? help me plz...

require("conn.php");
$sql = "select * from pemohon where id='$_GET[id]';";
$result = mysql_query($sql);
    while($row = mysql_fetch_array($result))
    {
        $sn = $_SESSION['SESS_NAME'];
        $sql = "update pemohon set admin='$sn',status_key='2' where id='$_GET[id]';";
        $result = mysql_query($sql);
        header("Location: admin.php?page=non_member_1");
    }
}
2
Contributors
11
Replies
40
Views
4 Years
Discussion Span
Last Post by iamthwee
0

i need to update 'admin' column in database with $_SESSION['SESS_NAME'] value.. but the admin column is blank, can't updated..

0

Echo out your variables to the screen before you do you sql.

Check if those variables are what you expect.

0

actually, status_key column is working, can update with value '2'. but admin column is not working.

0

Check $_SESSION['SESS_NAME']; is not empty or contains bad characters.

And that the table name 'admin' is spelt correctly and has the correct upper/lowercase. Judging by what you've written (I've not had a chance to test this) but I would say sess_name is empty or being called wrong.

Edited by iamthwee

0

if i use echo "welcome ".$_SESSION['SESS_NAME']; the output will return welcome DIANA

0

Well if you have a value in the admin table equal to 'DIANA' all upper case the only thing left I can think of is that while loop might not be executing once but possibly another time.

To eliminate this as a possibility do this:

    // $sn = $_SESSION['SESS_NAME'];
    $sn = 'DIANA';
    $sql = "update pemohon set admin='$sn',status_key='2' where id='$_GET[id]';";
    $result = mysql_query($sql);
    header("Location: admin.php?page=non_member_1");

^So comment out the first line and run the query again. Does that work?

Edited by iamthwee

0

no, i can't do that, bcoz i need each row updated by different admin.. and admin's name depends on $_SESSION['SESS_NAME']..

0

Yes I know that but I just wanted to see if you hardcode it, it actually updates the database.

Just try it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.