Loathorhealer Posted March 25, 2006 Share Posted March 25, 2006 [code] if ($logged_in == 1) { echo 'welcome back '.$_SESSION['username'].''; $query = sprintf("SELECT firstname, lastname FROM users WHERE ("$logged_in == 1")");$result = mysql_query($query);if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message);}while ($row = mysql_fetch_field($result)) { echo $row['firstname']; echo $row['lastname'];}mysql_free_result($result);[/code]okay. I get this error[code]Parse error: syntax error, unexpected T_VARIABLE in /home/.navy/loathor/squaresyndicate.com/welcome.php on line 13[/code]and I know its becuase of the $logged_in <-- deal. but I need it to display the firstname and the lastname of the person Just logged in. can you help? Link to comment https://forums.phpfreaks.com/topic/5732-help-with-query/ Share on other sites More sharing options...
Gast Posted March 25, 2006 Share Posted March 25, 2006 [!--quoteo(post=358109:date=Mar 25 2006, 12:50 AM:name=Loathorhealer)--][div class=\'quotetop\']QUOTE(Loathorhealer @ Mar 25 2006, 12:50 AM) [snapback]358109[/snapback][/div][div class=\'quotemain\'][!--quotec--][code] if ($logged_in == 1) { echo 'welcome back '.$_SESSION['username'].''; $query = sprintf("SELECT firstname, lastname FROM users WHERE ("$logged_in == 1")");$result = mysql_query($query);if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message);}while ($row = mysql_fetch_field($result)) { echo $row['firstname']; echo $row['lastname'];}mysql_free_result($result);[/code]okay. I get this error[code]Parse error: syntax error, unexpected T_VARIABLE in /home/.navy/loathor/squaresyndicate.com/welcome.php on line 13[/code]and I know its becuase of the $logged_in <-- deal. but I need it to display the firstname and the lastname of the person Just logged in. can you help?[/quote]What is actually stored in the variable $logged_in? Link to comment https://forums.phpfreaks.com/topic/5732-help-with-query/#findComment-20643 Share on other sites More sharing options...
annihilate Posted March 25, 2006 Share Posted March 25, 2006 Is there a session variable for a userid or something?Then you can just do your query like so:[code]$query = sprintf("SELECT firstname, lastname FROM users WHERE userid = '".$_SESSION['userid']."'");[/code] Link to comment https://forums.phpfreaks.com/topic/5732-help-with-query/#findComment-20658 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.