Tuesday, 17 September 2013

Is my return written correctly for this type of connection?

Is my return written correctly for this type of connection?

My return is not returning back anything when attempting to find a
username, the sql is able to connect. Here is my code:
function usernameExists($username) {
global $conn;
$sql = "SELECT active FROM user
WHERE username='" . fixstr($username) . "' LIMIT 1";
if(returns_result($sql) > 0) {
return true;
} else {
return false;
}
}
Here is my connection:
/* Create a new mysql connect object with database connection parameters */
$conn = mysql_connect(db_server, db_user, db_pass);
if (!$conn)
die("Could not connect: " . mysql_error());
mysql_select_db(db_name, $conn);
My connection is not able to return anything but it does connect to the
server through fixstr.
Here is fixstr:
function fixstr($str){
$str = trim($str);
$str = str_replace("'", "''", $str);
return $str;
}
Why is my return not returning any results.

No comments:

Post a Comment