if I have a script like this: <?php $fetch_users_data = mysql_fetch_object(mysql_query("SELECT * FROM `members` WHERE username='".$_SESSION['username']."'")); $ref_id=$fetch_users_data->id; if(isset($_GET['join'])){ $referral_ID = $_GET['join']; $referral_string= "?join=".$referral_ID; } $membername= $fetch_users_data->username; //don't change ?> Code (markup): and I want to add a $subid whitch code is correct: $subid = $_SESSION['username']; Code (markup): or $subid = $membername; Code (markup): please someone who knows php and not just quesses. Thx guys. let me explain a bit better what I want. I want $subid to be the username curently logged in.
Well since you already have the username stored in a session variable ( it's being used in the first query to query the database to fetch the users data), then you should just use the session variable. Also, if you want to use this on more than just the current page, you will have to use sessions. If you assigned the username to a regular variable, it would be lost as soon as you left the page. Another thing, is that if the query should happen to fail, then $membername would not be set.