Unknown column '$userId' in 'where clause'

the link is my code
i get a error when i try put it in sql in phpmyadmin and another in the website

anyone know how to fix this? what am i doing wrong i am bad at english sorry the link is to see my code, hope it helps

SELECT Beskeder.Id, Beskeder.Overskrift, Beskeder.Besked, Kategorier.Kategorinavn
FROM Beskeder
INNER JOIN Kategorier
ON Beskeder.FK_KategoriId = Kategorier.Id
WHERE Beskeder.FK_brugerId = $userId
ORDER BY Beskeder.Id DESC
LIMIT 0, 25
MySQL returned: Documentation

#1054 - Unknown column ‘$userId’ in ‘where clause’**


this error i get if i try on site Notice: Undefined index: userId in C:\Xampp\htdocs\initializr_soren\admin\index.php on line 222 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ORDER BY Beskeder.Id DESC’ at line 5

line 222 is: $userId = $_SESSION[“userId”];


Where are you setting the Session for user_id?

sorry about wasting your all time, it seems there wasnt a problem at all, i just forgot to login. ./

Sponsor our Newsletter | Privacy Policy | Terms of Service