rofl: Falscher MySQl Syntax

Beitrag lesen

Hallo.

Ich habe folgendes vor:
Ich will in meiner Datenbank nachschauen ob ein Eintrag schon vorhanden ist.

Quelltext:
$name="lolrofl"
$q=mysql_query("SELECT id FROM $table WHERE name='$name'") or die (mysql_error());
if(mysql_num_rows($query)>0){header('Location: ZIELADRESSE');}

Es kommt folgende Fehlermeldung:
"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 'WHERE name='lolrofl'' at line 1"

Woran liegt das?

Hoffe auf baldige Hilfe.

mfg

Rolf