okok.
if you are defining a string in PHP and you start it with double quotes (") then the next double quote mark you find is interpreted by PHP to be the END of that string. that means that if you want to define a string with quotes in it, you are going to have to 'escape' them with a backslash. like this:
$my_string = "Here is how you \"escape\" quotes to get them in a string";
echo $my_string;
in your code, your string is all mangled...
$result2 = mysql_query ("SELECT * from members where username = '$_SESSION["valid_user"]');
you start with a double quote, then you have double quotes inside in your reference to your session variable which ends your string and starts a new one and then you fail to terminate the string you originally tried to start at all.
in general, if i'm referring to an associative array like $_SESSION["valid_user"] in a string, i don't try to use PHPs very handy string behavior...i explicitly concatenate it--OR assign it to an innocuous temporary string variable first.. helps me avoid all the quote confusion.
either of these should work:
$result2 = mysql_query ("SELECT * from members where username = '" . $_SESSION["valid_user"] . "';");
// OR
$tmp_valid_user = $_SESSION["valid_user"];
$result2 = mysql_query ("SELECT * from members where username = '$tmp_valid_user';");
it's critical to learn how to find syntax errors. your code won't run if there's a single one in there. i didn't scan your code...there could be others.