PHP mySQL query's and PHP Variables
- by jon
I'm trying to make an OO Login system for a project I'm working on, and am having trouble with inserting variables into the query strings. In the code below, if I replace "$TBL_NAME" with the actual table name it works. Why isn't $TBL_NAME translating to the value of $TBL_NAME?
class UserDB {
private $TBL_NAME = "users";
public static function CheckLogin($username, $password) {
Database::Connect();
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$sql="SELECT uid FROM $TBL_NAME WHERE username='$username' AND password='$password' ";
$result =mysql_query($sql);
$count=mysql_num_rows($result);
if ($count==1)
return true;
else
return false;
}
The Query is returning false.