In an SQL query the table , database and field names used a ` (prime)
never trust the session variables, use the cast functions on the session variables.
if you wanted to re-use a field ( $row['id'] ), select it in your query.
In html use the & sign as an html entitie: &
<?php
if ( !empty( $_SESSION['uid'] ) )
{
$sql = sprintf( "SELECT `id`,`username` FROM `users` WHERE `id`=%d", $_SESSION['uid'] );
$res = mysql_query( $sql ) or die ( mysql_error() );
if ( mysql_num_rows( $res ) == 0 )
{
session_destroy();
echo "Please <a href=\"./login.php\">Login</a> to your existing account or <a href=\"register.php\">Register</a> a new account!\n";
}
else
{
$row = mysql_fetch_assoc( $res );
echo "Welcome back, <a href=\"./index.php?act=profile&id=" . $row['id'] . "\">" . $row['username'] . "</a>!\n";
}
}
else
{
echo "Please <a href=\"./login.php\">Login</a> to your existing account or <a href=\"register.php\">Register</a> a new account!\n";
}
?>