Jump to content

Archived

This topic is now archived and is closed to further replies.

Loathorhealer

Help with Query

Recommended Posts

[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?

Share this post


Link to post
Share on other sites
[!--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?

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.