function SalvaLivello($id_razza, $id_classe, $livello) { include "config.inc.php"; $id_user = GetIdUser($db); $data = date('Y-m-d H:i:s'); // Verifica unicita' livello: $q_ver = "select * from tab_livelli where id_razza='{$id_razza}' AND id_classe='{$id_classe}'"; $r_ver = mysql_query($q_ver, $db) or die(StampaErr($q_ver)); $n_ver = mysql_affected_rows($db); // Se non c'e' una coppia classe livello salvata aggiungila: if ($n_ver == 0) { $q_save = "insert into tab_livelli (id_razza, id_classe, livello, id_user, data) " . "values ('{$id_razza}', '{$id_classe}', '{$livello}', '{$id_user}', '{$data}')"; $r_save = mysql_query($q_save, $db) or die(StampaErr($q_save)); $msg = "<label class=\"ok\">Livello salvato correttamente.</label>"; SessionLog("[Debug][SalvaLivello]: {$q_save}", $db); } else { $msg = "<label class=\"err\">Livello già presente, salvataggio annullato.</label>"; } mysql_close($db); return $msg; }
function DeleteRows($Tab, $Where, $db, $debug = 1) { $q = "DELETE FROM {$Tab} Where {$Where}"; $r = mysql_query($q, $db) or die(StampaErr($q, '[DeleteRows] ')); if ($debug != 1) { echo "[Debug][DeleteRows]: {$q} <br />"; } SessionLog("[Debug][DeleteRows]: {$q}", $db); $_SESSION['last_query'] = $q; return TRUE; }