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 'and length(published)>0 order by sort asc, phDate desc' at line 1 select phId, phNameru, date_format(phDate,'%d.%m.%Y') from tbphoto where sprId= and length(published)>0 order by sort asc, phDate desc Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/pll.imco.md/html/classes/class.main.php on line 154