Questo è il mio file php

codice:
<?php

require("config.php");


if ($_COOKIE['username'] == FALSE && $_COOKIE['password'] == FALSE) {
echo "Sessione amministrativa scaduta.";
header("Location: ac-panel.php");
} else {


echo "<font size=\"4\"><a href=\"ac-panel.php\">Home Pannello</a> | <a href=\"ac-control.php\">Preferenze</a></font>

";
echo "<a href=\"ac-categorie.php?do=new\">Crea una nuova categoria</a> | <a href=\"ac-categorie.php?do=edit\">Modifica categorie</a>

";

if ($_GET['do'] == "new") {
echo "<form action=\"\" method=\"POST\">";
echo "Nome: 
<input type=\"text\" name=\"nome\">
";
echo "Descrizione: 
<input type=\"text\" name=\"desc\">
";
echo "<input type=\"submit\" value=\" >> Crea\">";
echo "</form>";

$nome = htmlspecialchars($_POST['nome']);
$desc = htmlspecialchars($_POST['desc']);

if ($nome == "" && $desc == "") {
echo "Compilare i campi";
} else {
$query = mysql_query("INSERT INTO categories (id, name, desc) VALUES (NULL, '$nome', '$desc')")or die(mysql_error()); 
$strSQL = mysql_query("SELECT * FROM categories");
$result = mysql_fetch_array($query);
if (! $result) {
echo "Categoria non creata";
exit();
} else {
echo "Categoria creata con successo";
}
}
}
if ($_GET['do'] == "edit") {
$query = mysql_query("SELECT * FROM categories");
$result = mysql_fetch_array($query);
if (! $result) {
echo "Nessuna categoria creata";
exit();
} else {
while ($result)
{
echo "[*]<a href=\"ac-categorie.php?do=edit&cat=$result[id]\">$result[title]</a>";
$result = mysql_fetch_array($query);
}
}
}
if($_GET['do'] == "edit" && htmlspecialchars($_GET['cat'])){
$query = mysql_query("SELECT * FROM categories");
$result = mysql_fetch_array($query);
echo "Dati relativi alla categoria selezionata

<form action=\"\" method=\"POST\">";
echo "Nome: <input type=\"text\" name=\"nome\" value=\"".$result[nome]."
";
echo "Descrizione: <input type=\"text\" name=\"desc\" value=\"".$result[desc]."
";
echo "<input type=\"submit\" value=\" >> Modifica\"></form>";
$nome = htmlspecialchars($_POST['nome']);
$desc = htmlspecialchars($_POST['desc']);
if ($nome == "" && $desc == "") {
echo "Compilare i campi";
} else {
$query = mysql_query("UPDATE categories SET name=".$nome." WHERE id=".$_GET['cat']."");
$query1 = mysql_query("UPDATE categories SET desc=".$desc." WHERE id=".$_GET['cat']."");
echo "Categoria modificata con successo";
header("Location: ac-categorie.php?do=edit");
}
}
}
?>
Nella pagina ac-categorie.php?do=new, dopo aver cliccato sul submit del form appare questo errore:
codice:
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 'desc) VALUES (NULL, 'Prova', 'ahaha')' at line 1
Questa sarebbe la query errata che a me sembra giusta:
codice:
$query = mysql_query("INSERT INTO categories (id, name, desc) VALUES (NULL, '$nome', '$desc')")or die(mysql_error());
Tabella e campi sono tutti a posto, non capisco perchè questo errore.

Grazie dell'eventuale aiuto.