Reputation: 1
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
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