I have a php login page that I already can establish a connection to the database. The problem comes when I try to login with an already existing user, I get a PHP Warning: pg_fetch_assoc() expects parameter 1 to be resource, null given . below is the whole query
$query = "SELECT * FROM users WHERE (pj = $username OR email like '$username') AND password = crypt('$password', password)";
echo "$query";
$result_users = pg_query($GLOBALS['conn'], $query);
if ($row = pg_fetch_assoc($result_users)){
Any ideas? thanks