user3286062
user3286062

Reputation: 1

echo inserted session(username) variable

session user id: $_SESSION['uid']

session username: $_SESSION['username']

variable: $creator = $_SESSION['uid'];

query:

$sql = "INSERT INTO posts (category_id, title, content, source, creator, date) 
        VALUES ('1', '".$title."', '".$content."', '".$src."', '".$creator."', now())";

problem: When I echo $row['creator'] the username doesnt appear in letters rather in numbers(0,1).

What I want: Creator: David

What it shows: Creator: 1

thnx!

Upvotes: 0

Views: 280

Answers (1)

John Conde
John Conde

Reputation: 219804

Without knowing what the actual values of your session variables it looks like you are assigning the wrong session variable to $creator. The uid array key indicates a numerical value. You are probably supposed to assigning $_SESSION['username'] to $creator instead:

$creator = $_SESSION['username'];

Upvotes: 2

Related Questions