Ho capito!!!
Mancava lo spazio

VECCHIO
$result = mysql_db_query("select l.*, c.materia
from lezioni l, categorie c
where l.IdLezione = " .$_GET['IdCategoria']. "a nd
c.IdCategoria = l.IdCategoria",$db_name) or die(mysql_error());
NUOVO
$result = mysql_db_query("select l.*, c.materia
from lezioni l, categorie c
where l.IdLezione = " .$_GET['IdCategoria']. " a nd
c.IdCategoria = l.IdCategoria",$db_name) or die(mysql_error());