1
I have a class where I use to get the username, and inside I have the method:
public function getfName() {
$Session = $_SESSION[$this->Prefix . 'username'];
$sql = "SELECT * FROM " . DB_DBPREFIX . "$this->Table WHERE name = $Session";
try {
$stmt = Conn::dbPrepare($sql);
$stmt->execute();
while ($row = $stmt->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_NEXT)) {
$data = $row[1];
print $data;
}
} catch (PDOException $e) {
echo $e->getMessage();
}
}
Only when I put the $Session variable in my query I get this error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'TheNight' in 'where clause'
I searched here on Stack and other sites and found a topic but did not help me, so I decided to open this!
Try to put it like this:
name='$Session'
in single quotes– dm707
@Diegomachado you almost got rsrs, the error disappeared more did not appear what I wanted, I want to take my name there on DB and print on the screen...
– Guilherme Alves