PHP mySQL query's and PHP Variables

Posted by jon on Stack Overflow See other posts from Stack Overflow or by jon
Published on 2010-05-29T19:01:59Z Indexed on 2010/05/29 19:12 UTC
Read the original article Hit count: 150

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql