$_GET Help

I want to get user information from a MySQL database. When the user goes to http://domainname .com/user.php?user=USERNAME, I want “USERNAME”'s info to be displayed, but it can never do the first query, I’m not sure if it is because the is an error in the query or in the get variable. Can someone find the error or tell me what I’m doing wrong? Thanks for the help!

<?php
require("includes/redirect.php");
$flatUName = $_GET['user'];
$flatSQL = "SELECT Username FROM sq_users WHERE Username = '$flatUName'";
$goSQL = mysql_query($flatSQL);
if(!$flatSQL) die(mysql_error());
if(0 == mysql_num_rows($goSQL)){
    header('Location: '. $root . $logOut);
	mysql_close($con);
	exit;
}

(If you need more code, just say.)

The result of your mysql_query call is stored in $goSQL, but you check $flatSQL (a string) for an error on the next line instead.

Other than that, the code looks alright (aside from being vulnerable to SQL injection)… so what exactly happens?

I’m currently focused on getting the basic code made. Once it is done and published, I will start getting help on updating it. I want to get good enough at mod_rewrite for more security.

All this code does is get information from a database and store it in variables, so it can be “echoed” back as user information.

I’m asking what the specific problem is. Presumably you posted this because you want help with something.

Is there an error message? If not, what is happening that isn’t what you expect?

You solved the problem. It was that the page would always redirect, even if the user name type in the URL existed. I didn’t know that judging the incorrect variable was the problem until you pointed it out to me.